reactjs 无法读取未定义的属性“pop”|| next.js

eqzww0vc  于 2023-11-18  发布在  React
关注(0)|答案(2)|浏览(135)

the screen shot of project $ npm run build

> [email protected] build
> next build

(node:31220) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at C:\Users\murtu\OneDrive\Desktop\myProject\nextjs_practice\new_practice\nextjs-blog\node_modules\postcss\package.json.       
Update this package.json to use a subpath pattern like "./*".
(Use `node --trace-deprecation ...` to show where the warning was created)
info  - Creating an optimized production build    
Failed to compile.

chunk 30cd56ec8b4292fd1d19f6bfd4b67b1689d06305_CSS
static/css/851b1bf4ba9315e79ff2.css
Cannot read property 'pop' of undefined

> Build error occurred
Error: > Build failed because of webpack errors
    at C:\Users\murtu\OneDrive\Desktop\myProject\nextjs_practice\new_practice\nextjs-blog\node_modules\next\dist\build\index.js:15:918
    at async C:\Users\murtu\OneDrive\Desktop\myProject\nextjs_practice\new_practice\nextjs-blog\node_modules\next\dist\build\tracer.js:1:525
npm ERR! code 1
npm ERR! path C:\Users\murtu\OneDrive\Desktop\myProject\nextjs_practice\new_practice\nextjs-blog
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c next build

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\murtu\AppData\Local\npm-cache\_logs\2020-12-24T13_03_26_358Z-debug.log

字符串
我正面临着这个问题,因为我已经尝试了许多解决方案,从互联网一样创建next.js.js该项目是完美的工作,而我正在使用这个一个npm run dev可以有人帮助我在这里什么是这里的问题,因为我已经说过,该项目是完美的工作在npm run dev。我真的厌倦了这个问题,请帮助我在这里。

xtfmy6hx

xtfmy6hx1#

即使你没有在你的帖子中提到它,我可以看到你正在使用NextJS。我今天只是偶然遇到了同样的问题,而没有真正对我们的应用程序进行任何更改。我发现对我们有效的修复方法是将以下内容添加到我们的next.js.js文件中。

// next.config.js

const nextConfig = {
  ... other NextJS configuration values,
  webpack(config) {
    if (config.optimization.splitChunks) {
      config.optimization.splitChunks.cacheGroups.shared = {
        name: 'app-other', // this needs to be a value that is different from what the other chunks in your app are using
        test: /\.css$/,
        chunks: 'all',
        enforce: true
      };
    },
    ...the rest of your Webpack config values
  }
};

module.exports = nextConfig;

字符串
希望这对其他人有用,并为他们节省一些时间。

cclgggtu

cclgggtu2#

我在升级node和npm版本时遇到了这个错误。我只是删除了package-lock.json和node-modules文件夹,然后安装了npm。问题解决了。

相关问题