由于 CentOS 7 上的 webpack 错误,nextjs 构建失败

时间:2021-03-31 21:38:41

标签: npm webpack next.js centos7

我想在 centos 服务器上部署 nextjs 应用程序。但是当我尝试使用 npm run build 进行构建时,它给了我以下错误


Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
info  - Creating an optimized production build
Failed to compile.

ModuleNotFoundError: Module not found: Error: Can't resolve '../context/auth/AuthState' in '/var/www/html/projectname/pages'


> Build error occurred
Error: > Build failed because of webpack errors
    at build (/var/www/html/projectname/node_modules/next/dist/build/index.js:15:918)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client-ubii-app@0.1.0 build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client-ubii-app@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-03-31T21_10_01_066Z-debug.log

但是当我在运行 Windows 10 的本地机器上做同样的事情时,它工作正常

1 个答案:

答案 0 :(得分:0)

如果您更改了文件名或文件夹的名称,仅区分大小写,如果您的远程分支未更新,则可能会发生此问题。请确保远程分支是否具有文件或文件夹的旧名称。如果为真,修复它,因为 CentOs 是 Linux,所以小写相同单词的文件和文件夹与大写不同。