gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 19:26:27 32 4
gpt4 key购买 nike

我的 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/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com