【发布时间】:2022-04-21 16:38:04
【问题描述】:
我不知道我的 PC 发生了什么,但每次我创建 NextJS 应用程序并运行开发时。它会返回这个错误
error - ./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[1]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[2]!./styles/globals.css
TypeError: Cannot read property 'config' of undefined
(node:20136) [DEP_WEBPACK_MODULE_ISSUER] DeprecationWarning: Module.issuer: Use new ModuleGraph API
(Use `node --trace-deprecation ...` to show where the warning was created)
wait - compiling /_error (client and server)...
error - ./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[1]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[2]!./styles/globals.css
TypeError: Cannot read property 'config' of undefined
at runMicrotasks (<anonymous>)
<w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: ENOENT: no such file or directory, rename 'C:\laragon\www\bayu-personal-website\.next\cache\webpack\client-development-fallback\0.pack_' -> 'C:\laragon\www\bayu-personal-website\.next\cache\webpack\client-development-fallback\0.pack'
我在我的项目中找不到任何导致此错误的原因,因为它发生在我运行 yarn create-next-app 和 yarn dev 之后。提前谢谢你。
【问题讨论】:
-
你为某些组件添加了css文件?
-
我是直接运行
npm run dev,没有对项目@H9ee做任何修改 -
我不知道如何安装下一个 js,但尝试安装这个包:npm install postcss-flexbugs-fixes postcss-preset-env
-
感谢您的回复,不幸的是它没有改变任何东西并且仍然返回错误@H9ee我会再试一次yarn
-
我会在这里尝试两件事:1. 删除你的 next.js 缓存:
rm -rf .next2. 确保你的项目是用 yarn 安装的,然后尝试用yarn dev运行你的项目(您在问题中提到了运行yarn dev,但在评论中提到了npm run dev)。