node.js - npm 运行构建中的 Nestjs "Reached heap limit Allocation failed - JavaScript heap out of memory"

标签 node.js ubuntu npm next.js nestjs

我的 Nest js API 有问题。
当我在本地构建时,一切正常,我可以毫无问题地构建和启动开发服务器,但是当我转到我的服务器时,我无法构建或启动开发服务器。
当我尝试运行“npm run build”、“yarn build”或使用“yarn start”启动服务器时, Node 返回给我这个错误:
enter image description here
我尝试运行“export NODE_OPTIONS=--max_old_space_size=4096”并在 ~/.bashrc 导出 Node 选项中使用更多空间。此外,我升级了所有依赖项,并再次删除并安装,但没有任何效果。我对使用 Next JS 的这个项目的前端有同样的问题。
服务器是一台 aws EC2 t3.small 服务器,Ubuntu 20.04.3 LTS,node 版本为 v17.3.0,npm 版本为 8.3.0,yarn 版本为 1.22.17。
当我运行“tsc --extendedDiagnostics --noEmit”时,我有 20 个来自 node_modules/@nestjs/config 的错误,我尝试更新包但不起作用:
enter image description here
最后,我得到了这个总结:
enter image description here
谢谢

最佳答案

好吧,在搜索解决方案几个小时后,我使用命令“sudo nest update --force”更新了 Nest 项目,我删除了 node_modules 并执行了“yarn install”。
在此之后,我使用“sudo chmod -R 777 ./”授予我的项目文件的所有权限,最后“npm run build”和“yarn build”工作。
非常感谢!

关于node.js - npm 运行构建中的 Nestjs "Reached heap limit Allocation failed - JavaScript heap out of memory",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70467410/

相关文章:

node.js - 如何在返回 Promise 的同时添加 catch

node.js - Node ExpressJS-events.js : 167 throw er Unhandled error event

ubuntu - 当我输入终端时,我看到其他字符 ubuntu

ruby-on-rails - libffi.so.6 : cannot open shared object file in rails

npm - 在 Windows 上运行 Npm 时如何修复 SSL 证书错误?

javascript - https post 在 javascript 中类似于带有 header 和参数的curl -d 和 "request"模块nodejs npm

javascript - 如何在客户端需要不同的 Node 模块?

linux - 创建到多个目录centos的符号链接(symbolic link)

javascript - Angular : ng build fails but npm run build works fine

node.js - 部署到 Azure 时出现 Npm 错误:fsEvents 平台不受支持