Home > other >  Nestjs "Reached heap limit Allocation failed - JavaScript heap out of memory" on npm run b
Nestjs "Reached heap limit Allocation failed - JavaScript heap out of memory" on npm run b

Time:12-26

I have an issue with my Nest js API.

When I build in local, all works fine and I can build and start the development server without problems, but when I go to my server I can't build or start the development server.

When I try to run "npm run build","yarn build" or start the server with "yarn start" the node returns to me this error:

enter image description here

I tried to run "export NODE_OPTIONS=--max_old_space_size=4096" and in the ~/.bashrc export de node options with more space. Also, i upgraded all dependencies, and deleted and installed again, but nothing works. I have the same issue with the frontend of this project that uses Next JS.

The server is an aws EC2 t3.small server with Ubuntu 20.04.3 LTS, the node version is v17.3.0, the npm version is 8.3.0 and the yarn version is 1.22.17.

When I run "tsc --extendedDiagnostics --noEmit" i have 20 errors from node_modules/@nestjs/config, I tried to update the package but doesn't work:

enter image description here

And finally, I get this summary:

enter image description here

Thanks

CodePudding user response:

Well, after few hours searching a solution I updated the nest project with the command "sudo nest update --force", I removed the node_modules and executed "yarn install".

After this, I granted all the permissions to my project files with "sudo chmod -R 777 ./" and finally the "npm run build" and "yarn build" worked.

Thanks a lot!

  • Related