npm install - javascript heap out of memory

前端 未结 6 431
面向向阳花
面向向阳花 2020-12-03 09:48

When running npm install -g ionic I get the following error:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of

相关标签:
6条回答
  • 2020-12-03 10:03

    You can launch NPM using :

    node --max-old-space-size=8000 $(which npm) install -g ionic

    As described here, the default is 4000 (4Gb).

    0 讨论(0)
  • 2020-12-03 10:11

    Solved for me, after running the command:

    npm update
    

    It will update all dependencies (be careful with broken changes). Maybe the webpack-cli dependency is the cause of this trouble.

    0 讨论(0)
  • 2020-12-03 10:13

    Try, node --max-old-space-size=<size> where size is in megabytes.

    0 讨论(0)
  • 2020-12-03 10:13

    I had an incorrect prefix in my .npmrc file. By moving to new company devices this path didn't match anymore with the old nodejs folder. On npm install the command freezes for a long time and throws an java out of heap exception without a suitable answer.

    I've deleted it and it worked.

    prefix=D:\development\nodejs
    
    0 讨论(0)
  • 2020-12-03 10:17

    I flagged this as a duplicate, but in case anyone happens across it, I posted the modern solution to this problem over at https://stackoverflow.com/a/48895989/4200039:

    As of v8.0 shipped August 2017, the NODE_OPTIONS environment variable exposes this configuration (see NODE_OPTIONS has landed in 8.x!). Per the article, only options whitelisted in the source are permitted, which includes "--max_old_space_size".

    So I put in my .bashrc: export NODE_OPTIONS=--max_old_space_size=4096

    0 讨论(0)
  • 2020-12-03 10:19

    Run these commands

    npm install -g increase-memory-limit

    Run from the root location of your project:

    increase-memory-limit

    Look Here For more details https://www.npmjs.com/package/increase-memory-limit

    0 讨论(0)
提交回复
热议问题