首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法生成包含自定义辅助文件的项目。

无法生成包含自定义辅助文件的项目。
EN

Stack Overflow用户
提问于 2021-03-23 11:01:42
回答 1查看 271关注 0票数 2

next-pwa面临着一个非常奇怪的问题。每当我试图构建包含自定义辅助器js文件的next-pwa项目时,生成都会失败,出现以下错误:

代码语言:javascript
复制
info  - Creating an optimized production build ..buffer.js:333
  throw new ERR_INVALID_ARG_TYPE(
  ^

TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
    at Function.from (buffer.js:333:9)
    at writeOut (C:\Users\sdqui\Desktop\next-pwa\examples\custom-worker\node_modules\next\dist\compiled\webpack\bundle4.js:56716:26)
    at C:\Users\sdqui\Desktop\next-pwa\examples\custom-worker\node_modules\next\dist\compiled\webpack\bundle4.js:56735:7
    at arrayIterator (C:\Users\sdqui\Desktop\next-pwa\examples\custom-worker\node_modules\next\dist\compiled\neo-async\async.js:1:14270)
    at timesSync (C:\Users\sdqui\Desktop\next-pwa\examples\custom-worker\node_modules\next\dist\compiled\neo-async\async.js:1:5037)
    at Object.eachLimit (C:\Users\sdqui\Desktop\next-pwa\examples\custom-worker\node_modules\next\dist\compiled\neo-async\async.js:1:14216)
    at emitFiles (C:\Users\sdqui\Desktop\next-pwa\examples\custom-worker\node_modules\next\dist\compiled\webpack\bundle4.js:56617:13)
    at C:\Users\sdqui\Desktop\next-pwa\examples\custom-worker\node_modules\next\dist\compiled\webpack\bundle4.js:36508:26
    at FSReqCallback.oncomplete (fs.js:184:5) {
  code: 'ERR_INVALID_ARG_TYPE'
}

到目前为止,我已经尝试了几件事情来解决这个问题:

  • 克隆回购和更新所有的依赖(我认为问题可能是webpack相关的)
  • 在没有自定义工作文件的情况下构建项目(工作正常)
  • 降级到节点10、12、14、15和重新安装依赖项。

我也尝试使用回购的/example文件夹中提供的/example,但同样的问题也发生在那里。

我不是唯一一个面临这个问题的人,所以我会感谢你的帮助。

您可以使用Gitpod自己测试它,只需打开这个链接并导航到示例,安装依赖项并尝试yarn build

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-26 15:37:19

你用webpack 5还是4 x?在webpack >5的情况下,我遇到了同样的问题,并通过将未来对象传递给withPWA“webpack5: true }”来修正相同的问题。

代码语言:javascript
复制
module.exports = withPWA({ future: { webpack5: true },
pwa: {
    disable: false,
    dest: "public",
    //register: false,
    skipWaiting: false,
    runtimeCaching
}

})

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66761853

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档