每次构建 Next.js 应用程序时,我都会收到弃用警告:
(node:10504) [DEP_WEBPACK_MODULE_UPDATE_HASH] DeprecationWarning: Module.updateHash: Use new ChunkGraph
API
(Use `node --trace-deprecation ...` to show where the warning was created)
按照建议去做(
cross-env NODE_OPTIONS='--trace-deprecation' next build
),我明白了:
(node:8508) [DEP_WEBPACK_MODULE_UPDATE_HASH] DeprecationWarning: Module.updateHash: Use new ChunkGraph API
at ChunkGraph.getChunkGraphForModule (*****\node_modules\next\dist\compiled\webpack\bundle5.js:28:48741)
at CssModule.updateHash (*****\node_modules\next\dist\compiled\webpack\bundle5.js:28:343372)
at CssModule.updateHash (*****\node_modules\next\dist\compiled\mini-css-extract-plugin\index.js:1:7125)
at Object.name [as getName] (*****\node_modules\next\dist\build\webpack-config.js:786:45)
at addModuleToChunksInfoMap (*****\node_modules\next\dist\compiled\webpack\bundle5.js:28:1124815)
at *****\node_modules\next\dist\compiled\webpack\bundle5.js:28:1127194
at Hook.eval [as call] (eval at create (*****\node_modules\next\dist\compiled\webpack\bundle5.js:13:28645), <anonymous>:31:16)
at Hook.CALL_DELEGATE [as _call] (*****\node_modules\next\dist\compiled\webpack\bundle5.js:13:25915)
at Compilation.seal (*****\node_modules\next\dist\compiled\webpack\bundle5.js:28:103411)
at *****\node_modules\next\dist\compiled\webpack\bundle5.js:28:148889
应用程序工作正常,构建也没有失败,但我想知道这个警告来自哪里以及如何修复它。
一些细节:
next: 14.1.0
npm: 10.4.0
node: 18.17.0
// next.config.js
const path = require('path');
const nextConfig = {
sassOptions: {
includePaths: [path.join(__dirname, 'styles')],
},
};
module.exports = nextConfig;
我尝试了删除
node_modules
、package-lock.json
和 .next
并再次安装软件包的经典方法,但没有帮助
更新到 14.2 似乎可以解决这个问题