【发布时间】:2020-12-03 23:51:10
【问题描述】:
我使用 Next JS 创建了一个 Web 应用程序,它在 npm run dev 上运行良好。但是当我尝试使用npm run build 在生产模式下运行它时,我得到了下面给出的错误。我尝试更改node_modules 目录的权限,运行npm install,尝试更新NodeJS 和NPM,但没有任何效果。我在互联网上也找不到太多关于此的内容。
> html@0.1.0 build /var/www/app/html
> next build
Creating an optimized production build
Failed to compile.
./node_modules/mysql/lib/protocol/sequences/Query.js
Module not found: Can't resolve 'fs' in '/var/www/app/html/node_modules/mysql/lib/protocol/sequences'
> Build error occurred
Error: > Build failed because of webpack errors
at build (/var/www/app/html/node_modules/next/dist/build/index.js:13:917)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! html@0.1.0 build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the html@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/2020-08-14T04_54_38_531Z-debug.log
【问题讨论】: