next-pwa面临着一个非常奇怪的问题。每当我试图构建包含自定义辅助器js文件的next-pwa项目时,生成都会失败,出现以下错误:
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'
}到目前为止,我已经尝试了几件事情来解决这个问题:
我也尝试使用回购的/example文件夹中提供的/example,但同样的问题也发生在那里。
我不是唯一一个面临这个问题的人,所以我会感谢你的帮助。
您可以使用Gitpod自己测试它,只需打开这个链接并导航到示例,安装依赖项并尝试yarn build。
发布于 2021-03-26 15:37:19
你用webpack 5还是4 x?在webpack >5的情况下,我遇到了同样的问题,并通过将未来对象传递给withPWA“webpack5: true }”来修正相同的问题。
module.exports = withPWA({ future: { webpack5: true },
pwa: {
disable: false,
dest: "public",
//register: false,
skipWaiting: false,
runtimeCaching
}})
https://stackoverflow.com/questions/66761853
复制相似问题