TypeError:无法读取 null 的属性“hash”,webpack
2021-10-02
351
我正在尝试构建我的 nextjs 项目,但每次都失败。项目在开发过程中没有任何错误,但在构建过程中失败。
尝试删除
node_modules
并重新安装软件包,但没有成功。
经过长时间的搜索,我终于找到了这个的 重复 ,但它已被作者删除。
构建日志
> next build
info - Loaded env from /home/user/Documents/projects/webdev/myproject/.env.local
info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
info - Checking validity of types
info - Creating an optimized production build .../home/user/Documents/projects/webdev/myproject/node_modules/next/dist/compiled/webpack/bundle5.js:59190
processContextHashSnapshot(path, tsh.hash);
^
TypeError: Cannot read property 'hash' of null
at callback (/home/user/Documents/projects/webdev/myproject/node_modules/next/dist/compiled/webpack/bundle5.js:59190:46)
at /home/user/Documents/projects/webdev/myproject/node_modules/next/dist/compiled/webpack/bundle5.js:57683:39
at /home/user/Documents/projects/webdev/myproject/node_modules/next/dist/compiled/webpack/bundle5.js:135587:5
at Hook.eval [as callAsync] (eval at create (/home/user/Documents/projects/webdev/myproject/node_modules/next/dist/compiled/webpack/bundle5.js:33832:10), <anonymous>:4:1)
at AsyncQueue._handleResult (/home/user/Documents/projects/webdev/myproject/node_modules/next/dist/compiled/webpack/bundle5.js:135557:21)
at /home/user/Documents/projects/webdev/myproject/node_modules/next/dist/compiled/webpack/bundle5.js:135540:11
at /home/user/Documents/projects/webdev/myproject/node_modules/next/dist/compiled/webpack/bundle5.js:59794:14
at /home/user/Documents/projects/webdev/myproject/node_modules/next/dist/compiled/webpack/bundle5.js:59452:6
at done (/home/user/Documents/projects/webdev/myproject/node_modules/next/dist/compiled/neo-async/async.js:1:10308)
at /home/user/Documents/projects/webdev/myproject/node_modules/next/dist/compiled/webpack/bundle5.js:59736:9
at /home/user/Documents/projects/webdev/myproject/node_modules/next/dist/compiled/webpack/bundle5.js:135587:5
at Hook.eval [as callAsync] (eval at create (/home/user/Documents/projects/webdev/myproject/node_modules/next/dist/compiled/webpack/bundle5.js:33832:10), <anonymous>:4:1)
at AsyncQueue._handleResult (/home/user/Documents/projects/webdev/myproject/node_modules/next/dist/compiled/webpack/bundle5.js:135557:21)
at /home/user/Documents/projects/webdev/myproject/node_modules/next/dist/compiled/webpack/bundle5.js:135540:11
at /home/user/Documents/projects/webdev/myproject/node_modules/next/dist/compiled/webpack/bundle5.js:59794:14
at /home/user/Documents/projects/webdev/myproject/node_modules/next/dist/compiled/webpack/bundle5.js:59452:6
2个回答
通过在部署期间使用
--force
标志清除 vercel 构建缓存来修复此问题。
Shawn C.
2021-10-05
删除
.next/
目录解决了我的问题。
bogdanoff
2021-10-02