2

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?

Nik
  • 1,093
  • 7
  • 26
  • 1
    So, you don't have much memory. Have you started up a bone dry program and checked how much free memory you have in node.js. You could just be legitimately running out of memory. moment.js is known for being kind of large when you're just using a few things from it. Also moment.js is now deprecated. – jfriend00 Sep 20 '20 at 19:06
  • npm was running with the following list of packages before I installed moment: popper jquery bootstrap history react-router-dom js-cookie reactstrap axios qs serve. I would replace moment but also "npm uninstall" fails with the same error. – Nik Sep 20 '20 at 19:47
  • You can just go into node_modules and erase the moment package directory. But, if you don't even have enough memory to run NPM, you have other problems. Perhaps do some reading/research about how to disable as many things as you can in the raspberry Pi configuration to preserve memory. – jfriend00 Sep 20 '20 at 19:56
  • I was able to run NPM with all packages up to the point where I added moment and tried to build a production build. If i have a large swap, should that not compensate for the memory? – Nik Sep 22 '20 at 09:52

0 Answers0