如何解决在运行npm run build
我已经使用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
解决方法
我终于找到了解决方法,问题已经解决。之所以出现此错误,是因为serverless-mysql
目录中有一些pages
个DB文件,并且在我将这些非页面文件移至页面目录之外之后,该错误消失了。
来源:https://github.com/vercel/next.js/issues/9768#issuecomment-663835978
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。