npm publish - out of memory - node.js

I'm on Windows (and using nvm). I want to publish a ~200mb module to our private npm repo but I get
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
I found out, that I should try to increase my memory usage. I'm not sure if I did it correctly because I'm on Windows and use nvm (currently using node v6.10.0), so my command looked like this:
node --max-old-space-size=4096 C:\\Users\\MyName\\AppData\\Roaming\\nvm\\v6.10.0\\node_modules\\npm\\bin\\npm-cli.js publish
but I ran into the same issue.
While doing so, I had a look into my task manager and the node process only allocated ~1.4GB memory - so how can I still have an out of memory error when my memory limit isn't reached? And, of course, how can I publish my module?

Related

How can I prevent React and Plotly crashing the development server due to JavaScript heap out of memory?

I am trying to build a create-react-app with react-plotly.js but when the plot components are included the compiler hangs and eventually fails displaying the error:
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
I checked the node heap limit using this command:
node -e 'console.log(`node heap limit = ${require("v8").getHeapStatistics().heap_size_limit / (1024 * 1024)} Mb`)'
which returned:
node heap limit = 1456.1747760772705 Mb
I am using the WSL 2 Linux subsystem for Windows.
I have tried editing the package.json and replacing react-scripts start
with node --max_old_space_size=4096 node_modules/.bin/react-scripts start as suggested in this answer but the error was the same. I have also tried reducing it and using 512 as I have read that is sometimes advised if there is not enough space on the machine.
Any ideas how I can get this to work?
I had success resolving this issue by disabling the GENERATE_SOURCEMAP flag in my .env file, ie
GENERATE_SOURCEMAP=false
as suggested by the (slightly unrelated) answer here.

npm CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

I am running nodejs on Ubuntu on a raspberry pi. I recently tried to install the moment package and now, when I am in my project directory, I get the following error whenever I run any command with npm:
FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
I am aware of answers to the seemingly same problem such as:
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory - webpack sample Angular 2
JS : CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
npm install - javascript heap out of memory
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
npm install - javascript heap out of memory
However, these approaches do not seem to work on my setup. I can't even run commands such as "increase-memory-limit" as any command I run with NPM will result in the error. I also tried reinstalling Nodejs, but it seems like that does not remove the packages. I tried to remove them with "npm uninstall ..." but as any other command with NPM this will result in the same error.
I should mention that my Raspi only has 850MB of memory, but I also added 6GB of swap.
Any suggestions how I might approach this issue?

Angular 8 error: '"node --max-old-space-size=10240"' is not recognized as an internal or external command

First I had the issue with limit allocation and I tried to resolve that using this answers here:
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory in ionic 3
But after that, I have this issue:
I didn't type this number 10240... I don't know where is this number from and how to solve the problem. Any idea?
Finally, I deleted the existing node module folder from my project and run the below commands:
npm install -all
npm audit fix
If anyone else is still having this issue: the solution for me was to run a script via node once, which converts all "%prog%" into %prog% in each cmd file in node-modules like this one

How to allocate more memory to my Virtual Machine running on Fedora to avoid Heap out of Memory Error

I'm running Jenkins on a Fedora Virtual Machine and have an app created by create-react-app .
When I try to build for production on my local machine, after ~8 minutes, it does get compiled successfully (although with the message: 'the bundle size is significantly larger than recommended...'
However, when I run the same script during my Jenkins build process, I get the following error: FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory.
The build script is as follows: npm run build-css && node --max_old_space_size=8192 node_modules/.bin/react-scripts-ts build && npm run copy-to-build.
My question is, how can I allocate more memory for my Virtual Machine running on Fedora so the script can run successfully before throwing the FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory .
The solution for me was to set GENERATE_SOURCEMAP=false in the .env.production file as described here.
A better solution (although more time consuming) is code split the huge files ( >1MB)

FATAL ERROR: JS Allocation failed when try to publish npm module

I'm trying to publish a module with:
npm publish ./
Following this gist: https://gist.github.com/coolaj86/1318304
But when I try to run this command I get the following error:
FATAL ERROR: JS Allocation failed - process out of memory
The npm process reaches 1.2 Gb in memory, but in my computer is more free ram, any ideas?
Turns out I had a huge ignored "tags" file in my root dir. It was 1.5Gb. I removed it and I was able to publish the package.
npm publish --dd provides some aditional info. I was able to check that the compressing was taking too long, which gave me the hint.

Resources