【问题标题】:nextjs Build failed because of webpack errors on CentOS 7由于 CentOS 7 上的 webpack 错误,nextjs 构建失败
【发布时间】:2021-06-27 22:19:21
【问题描述】:

我想在 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 时,它工作正常

【问题讨论】:

  • 您如何在 CentOS 机器上构建/运行应用程序?你使用 Docker 吗?

标签: npm webpack next.js centos7


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2020-11-27
    • 2022-11-02
    • 2021-07-02
    • 2019-10-15
    • 2021-12-08
    • 2021-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多