andeersg
By:
andeersg

NPM gets killed no matter what.

October 29, 2014 55k views

I have a droplet with Ubuntu 12.04 where i have installed node and npm. But no matter what i try, npm works a little and the gets "killed". It happens if i try "npm update" or "npm install".

Anyone know what causes this and if there is a solution?

7 comments
8 Answers

I found a solution that seems to work. I upgraded my swap-file to 1gb from 500mb ca.

Then i could install modules again.

I followed these instructions to do it.

by Etel Sverdlov
Linux swaps allow a system to harness more memory than was originally physically available. Here's how to set up a linux swap file on Ubuntu 12.04
  • It worked! I had exactly the same problem, and it seems that I had no swap file at all. After creating a 1GB swap file, npm kept installing all the packages till the end. Thanks a lot for sharing this!

Try running npm in verbose-mode, and post the results if you still can't figure out what happened.

npm --verbose install <package>
  • npm http GET https://registry.npmjs.org/lodash._isnative
    npm verb request where is /lodash.isobject
    npm verb request registry https://registry.npmjs.org/
    npm verb url raw /lodash.isobject
    npm verb url resolving [ 'https://registry.npmjs.org/', './lodash.isobject' ]
    npm verb url resolved https://registry.npmjs.org/lodash.isobject
    npm verb request where is https://registry.npmjs.org/lodash.isobject
    npm info trying registry request attempt 1 at 08:22:30
    npm verb etag "CPWRI1IP3U8NTU89SB3AHKA9H"
    npm http GET https://registry.npmjs.org/lodash.isobject
    npm verb request where is /lodash._shimkeys
    npm verb request registry https://registry.npmjs.org/
    npm verb url raw /lodash._shimkeys
    npm verb url resolving [ 'https://registry.npmjs.org/', './lodash._shimkeys' ]
    npm verb url resolved https://registry.npmjs.org/lodash._shimkeys
    npm verb request where is https://registry.npmjs.org/lodash._shimkeys
    npm info trying registry request attempt 1 at 08:22:30
    npm verb etag "DZ6P032FLD78S0R91BMU2WH7"
    npm http GET https://registry.npmjs.org/lodash._shimkeys
    npm verb registry.get https://registry.npmjs.org/lodash.keys not expired, no request
    npm verb registry.get https://registry.npmjs.org/lodash.keys not expired, no request
    npm verb request where is /lodash._escapehtmlchar
    npm verb request registry https://registry.npmjs.org/
    npm verb url raw /lodash._escapehtmlchar
    npm verb url resolving [ 'https://registry.npmjs.org/', './lodash._escapehtmlchar' ]
    npm verb url resolved https://registry.npmjs.org/lodash._escapehtmlchar
    npm verb request where is https://registry.npmjs.org/lodash._escapehtmlchar
    npm info trying registry request attempt 1 at 08:22:30
    npm verb etag "3ILFQWIDQTJSRWFEDZ8ZQ3I"
    npm http GET https://registry.npmjs.org/lodash._escapehtmlchar
    npm verb request where is /lodash._reunescapedhtml
    npm verb request registry https://registry.npmjs.org/
    Killed
    

    This is the last lines, it gets a little bit farther every time, so i'm guessing it runs out of memory or something.

    I have a droplet with 512mb of ram.

Created the swap file. Solved all my issues. Was also trying to get started using Keystone.js / node / Express

I have the same problem. Is there a workaround?

EDIT: Maybe it's possible to create a gulp task that runs npm install in batches... I might look into that when I have free time on my hands.

Use npm i --production dependencies less if it is replaced

Try install through the script:
https://gist.github.com/SuperPaintman/851b330c08b2363aea1c870f0cc1ea5a

npm-f3-install all
npm-f3-install production
npm-f3-install development
  • I know this thread is old but maybe a simple detail helps.

    I have 512mb RAM with no root access and had the same issue. I was receiving "killed" message even running npm-f3-install script (all, production or development).

    The sollution was simple, just run "npm-f3-install all -s" or "npm-f3-install all --silent".

    It's a silent mode, without those outputs that consume memory.
    Worked for me.

    By the way, thanks for the script, SuperPaintmanDe.

From what I understand, this happens when the process is taking too many resources for you droplet. What worked for me was installing all my required packages one by one, but I assume this could also be done using a shell script.

To solve this problem if you don't want to increase RAM you can resize swp

Have another answer? Share your knowledge.