【问题标题】:NextJS getting error on the first npm run devNextJS 在第一次 npm run dev 时出错
【发布时间】: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-appyarn dev 之后。提前谢谢你。

【问题讨论】:

  • 你为某些组件添加了css文件?
  • 我是直接运行npm run dev,没有对项目@H9ee做任何修改
  • 我不知道如何安装下一个 js,但尝试安装这个包:npm install postcss-flexbugs-fixes postcss-preset-env
  • 感谢您的回复,不幸的是它没有改变任何东西并且仍然返回错误@H9ee我会再试一次yarn
  • 我会在这里尝试两件事:1. 删除你的 next.js 缓存:rm -rf .next 2. 确保你的项目是用 yarn 安装的,然后尝试用 yarn dev 运行你的项目(您在问题中提到了运行yarn dev,但在评论中提到了npm run dev)。

标签: reactjs webpack next.js


【解决方案1】:

我设法在 Users/ 目录上创建了 nextJS 项目,结果证明可以修复错误。在此之前,我在 Users/ 目录之外创建了项目(直接在 C: 上并在那里创建文件夹)。所以可能是权限的事情导致项目无法运行。

【讨论】:

    【解决方案2】:

    我遇到了同样的问题,我通过重新启动 IDE 解决了这个问题,它可以正常工作!!

    【讨论】:

    • 这很奇怪,但在我的情况下也不起作用。我必须更改目录项目才能使其工作
    猜你喜欢
    • 2022-01-14
    • 2018-07-16
    • 2018-12-12
    • 2023-01-09
    • 1970-01-01
    • 1970-01-01
    • 2017-12-28
    • 2018-02-26
    • 2019-01-09
    相关资源
    最近更新 更多