如何修复 next.js 错误:错误:> 由于 webpack 错误而构建失败

问题描述 投票:0回答:4

我正在尝试将 next.js 应用程序部署到 netlify 并尝试获取输出文件夹,但是当我运行“npm run build”时,我收到如下错误:错误:> 由于 webpack 错误而导致构建失败 在构建时(C:\Users\Owner\Desktop\port_frontend 颂歌模块 ext\dist uild\index.js:15:918)

next.js netlify deploying
4个回答
1
投票

对于我的情况,删除

node_modules
文件夹,然后运行
yarn install
对我有用


0
投票

再次尝试安装软件包,你没有更新最新的;

npm install
npm run build

yarn install
yarn build

0
投票

要修复 CSS 优化过程中 cssnano 导致的 Webpack 构建错误,可以暂时禁用最小化。

将其添加到您的 next.config.ts

webpack: (config) => {
config.optimization.minimize = false;
return config;
},

这解决了我的问题,但这只是临时解决方案。


-1
投票

将 import next/App 更改为小写,它对我有用

© www.soinside.com 2019 - 2025. All rights reserved.