240

What does ELIFECYCLE mean?

Here's my app code: https://gist.github.com/samholmes/388ca4552c5936b52c5d

When I run the 'blast-emails' command, it will run for a while until shortly crashing with the error:

npm ERR! Linux 3.2.0-4-amd64
npm ERR! argv "/root/.nvm/versions/io.js/v1.6.1/bin/iojs" "/root/.nvm/versions/io.js/v1.6.1/bin/npm" "run" "live"
npm ERR! node v1.6.1
npm ERR! npm  v2.7.1
npm ERR! code ELIFECYCLE
npm ERR! emailer@0.0.0 live: `NODE_ENV=production node app.js`
npm ERR! Exit status 137
npm ERR! 
npm ERR! Failed at the emailer@0.0.0 live script 'NODE_ENV=production node app.js'.
npm ERR! This is most likely a problem with the emailer package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     NODE_ENV=production node app.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls emailer
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /apps/emailer/npm-debug.log

The npm-debug.log file is also included in the gist.

I'm looking for one of two answers: What does ELIFECYCLE mean? (or) Why am I getting the error in my application code?

Sam
  • 6,414
  • 11
  • 46
  • 61
  • Just received the same error from my webpack process (hadn't restarted in a few hours, and I made a change that broke the webpack build). Otherwise I've never seen the error before, and restarting the process resolved the issue. – Ally Apr 01 '16 at 04:32
  • 2
    ps -ax | grep npm ..and kill the npm processes worked for me – Buminda Dec 19 '18 at 13:28

18 Answers18

69

It's basically saying it fails to spawn your process not due to permission but to an error in your script. Source

You don't have any problem executing NODE_ENV=production node app.js ?

Pierre Inglebert
  • 3,858
  • 1
  • 18
  • 22
  • I don't have any problems executing the script. In fact, it works fine. I only get this error when running 'blast-emails' which does an async.eachSeries loop and sends out emails using nodemailer and the mandrill transport at you can see in the source code. Could it be an issue with nodemailer or the transport? – Sam Jun 10 '15 at 07:41
  • in emailer.js, there are references to a 'error' function but i can't find it. – Pierre Inglebert Jun 10 '15 at 07:46
  • which function in emailer.js? – Sam Jun 11 '15 at 18:12
  • this one for example : https://gist.github.com/samholmes/388ca4552c5936b52c5d#file-app-js-L57 – Pierre Inglebert Jun 11 '15 at 18:16
  • The error function is defined below within that scope: https://gist.github.com/samholmes/388ca4552c5936b52c5d#file-app-js-L81 – Sam Jun 11 '15 at 18:33
  • Maybe the issue is that the command run in replicon is running for too long? – Sam Jun 11 '15 at 18:36
  • NPM spawn your process when you executes npm run. – Pierre Inglebert Jul 21 '15 at 22:19
  • If the problem is with NPM, then why the delay before I get this error? – Sam Jul 21 '15 at 22:24
  • The problem is not with npm, your log says just that your process failed. The real cause must be above the log you paste. – Pierre Inglebert Jul 21 '15 at 22:28
  • So, it must be the `blast-emails` command, maybe? https://gist.github.com/samholmes/388ca4552c5936b52c5d#file-app-js-L155 When running this command, it takes awhile to complete. It goes through the rows from the second query and sends out an email to each subscriber, continuously logging to whom it sent an email. So, that's what happens before I get the error (somewhere in the middle of this blast-emails command, it crashes). – Sam Jul 21 '15 at 22:38
  • I found a solution by running npm install. There was a missing software in my project – Tuvia Khusid Oct 20 '16 at 00:14
48

One might think this is because outdated versions of npm and node, but it's not the case.

Just as Pierre Inglebert says, if you look into the source you can see that End of lifecycle means the program unexpectedly stopped. This can have various reasons. So it's not a syntax error and not an expected exception/error.

The error appeared to me when a different tool was already using the http port (3000) defined in my node scripts. When you run your node app on port 80, make sure you have stopped Apache webserver (as an example).

Tim
  • 5,435
  • 7
  • 42
  • 62
Daniel W.
  • 31,164
  • 13
  • 93
  • 151
  • 2
    Same for me, the port was used by another program – stalk Mar 02 '18 at 03:59
  • Then you can go to https://stackoverflow.com/questions/39632667/how-to-kill-a-currently-using-port-on-localhost-in-windows – hestellezg Apr 18 '18 at 21:32
  • 1
    In my case I didn't notice the `Error: listen EADDRINUSE :::3000` warning – hestellezg Apr 19 '18 at 16:49
  • 1
    The error is really ambiguous if you're using an old version of node/npm, I thought I had to upgrade, instead it was simply a download failed – Alex Jan 14 '19 at 12:15
26

In my case, it was because of low RAM memory, when a photo compression library was unable to process bigger photos.

Mehrdad Pedramfar
  • 10,941
  • 4
  • 38
  • 59
Mardari
  • 1,163
  • 11
  • 18
  • 1
    I got the same problem, it's because of the memory shortage. – Envil Jul 05 '18 at 09:29
  • 3
    Same! It seems ELIFECYCLE errno 137 can be caused by running out of memory too. In my case my server had 1Gb RAM. Upgraded it to 2Gb and my build passed. – Firze Jan 24 '19 at 12:05
  • 1
    I ran `npm run watch` under Docker and got the error from the question. When I increased the memory and CPU limits of docker, the problem has gone. – Paul Basenko Mar 04 '19 at 14:24
  • Had the same issue. Here's how I get rid of memory shortages : https://stackoverflow.com/a/34998803/2472389 – Balmipour Dec 15 '20 at 15:47
  • yep, out of memory problem was the issue here too – Tahbaza Jun 29 '21 at 01:13
14

While working on a WordPress theme, I got the same ELIFECYCLE error with slightly different output:

npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/Cellar/node/7.6.0/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v7.6.0
npm ERR! npm  v3.7.3
npm ERR! code ELIFECYCLE
npm ERR! foundationsix@1.0.0 postinstall: `bower install && gulp build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the foundationsix@1.0.0 postinstall script 'bower install && gulp build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the foundationsix package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     bower install && gulp build

After trying npm install one more time with the same result, I tried bower install. When that was successful I tried gulp build and that also worked.

Everything is working just fine now. No idea why running each command separately worked when && failed but maybe someone else will find this answer useful.

Matthew Read
  • 1,365
  • 1
  • 30
  • 50
adam-asdf
  • 646
  • 7
  • 16
  • @Matthew Read - How did you reformat that code block? It's a definite improvement but I'm not sure how to do it myself...I think I used to use 3 back ticks, hit 'enter' for a new line, then my code (followed by 'enter' and 3 back ticks to close the code block), but that doesn't seem to work for me anymore. Pointers? – adam-asdf Mar 24 '17 at 01:49
  • If you click on the "edit X hours/days ago" above my name there, then click "source", it will show you! Just a preformatted text tag. The other option would have been to indent each line by 4 spaces. Stack Overflow doesn't support the triple-backtick syntax like GitHub/Slack/etc. -- your formatting ended up being interpreted as three consecutive single-backticked blocks, with the first and last being completely empty (which is why the first line was very slighted indented and the last line had a tiny bit of highlighted space at the end). – Matthew Read Mar 24 '17 at 03:20
  • In my case, I forgot to run `npm install` (I'm new to node.js). Your answer led me in the right direction. Thanks. – Kon Nov 27 '18 at 21:57
6

When running Webpack build I was getting similar error because node doesn't understand async await keywords on older versions. I added webpack babel-plugin-transform-async-to-generator and it was solved. This replaces them with promises.

ahmadalibaloch
  • 5,851
  • 2
  • 50
  • 59
6

If you came here like I did, after receiving a similar error when trying the React Getting Started guide, you might like to know that the problem could have been caused by not having installed Watchman. Download it here, or install it with Homebrew with brew install watchman and try again: https://facebook.github.io/watchman/docs/install.html

PS: You might want to do a brew update first.

Community
  • 1
  • 1
Magne
  • 16,401
  • 10
  • 68
  • 88
  • Thanks... trying to learn just how to build someone else's react.native github checkin has been brutal. So many inaccurately documented setup steps! – Dronz Oct 23 '18 at 17:38
  • Is Watchman needed? It wasn't mentioned in the React Native setup instructions. – Dronz Oct 23 '18 at 17:40
  • 1
    @Dronz Yeah, apparently.. Don't know why. – Magne Oct 24 '18 at 16:05
  • Even on Windows? I thought Watchman was just something to help install things that's recommended for setting up React Native on Mac? – Dronz Oct 24 '18 at 17:16
  • 1
    @Dronz Not sure. I needed it on my Mac. – Magne Oct 28 '18 at 14:31
  • 1
    Thanks. It seems not to be needed on Windows. – Dronz Oct 29 '18 at 04:55
  • 1
    I was configuring a pre-built template in WordPress to pick up with the development team, got the same error and changing the line `cwd: parseInt(process.versions.node) < 8 ? process.cwd : process.cwd()` suppressed the error but generated another one ... `brew update` worked for me. – Shimanyi Valentino Nov 27 '18 at 13:38
5
at process._tickCallback (internal/process/next_tick.js:10
4:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ng-contact-manager@0.0.0 sample: `node src/server/dat
a/seed-db.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ng-contact-manager@0.0.0 sample script.
npm ERR! This is probably not a problem with npm. There is lik
ely additional logging output above.

npm ERR! A complete log of this run can be found in:

I have the same issue here is how I got solved finally! the error: my error from the terminal when i run npm run sample after correcting my database connection username and password I was using mlab for my database and under the file .env i forget to properly put the user name and password. When I correct that I works.

> ng-contact-manager@0.0.0 sample /Users/mohammedr.kemal/Downl
oads/Ex_Files_ANGULAR_API_AUTH/Exercise Files/Ch01/01_04/start
> node src/server/data/seed-db.js

connected to mongodb...
connected to mongodb...
2 records inserted.
closing connection...
done.
12 records inserted.
closing connection...
done.

So it might be good to look any data connection we made in our code if we have.

Buh Buh
  • 7,443
  • 1
  • 34
  • 61
Moh K
  • 484
  • 1
  • 4
  • 17
4

I had the same error after I installed new packages or updated them:

...
npm ERR! code ELIFECYCLE
npm ERR! errno 1
...

It helped me to run installation command once again or a couple of times. After that, the error disappeared.

Roman
  • 19,236
  • 15
  • 93
  • 97
3

I had this issue when I was running two projects that had the same set up and I already had one running. This meant that the other project couldn't use that port number. As soon as I stopped the other project running I had no issues.

Laura Smith
  • 35
  • 1
  • 4
2

This issue can also occur when you pull code from git and not yet installed node modules "npm install".

1

The Windows solution is the same as the Linux sudo answer. Run the npm start (or whatever) as Administrator. I had added a new module to my project. Worked on some machines but on others that were more locked down, not so much. Took a while to figure it out but the new module needed access to "something" that wasn't available without administrator permissions.

dbrouwer2
  • 31
  • 2
1

First, you will have to remove the npm cache and upgrade to the latest version of the node and npm will resolve the issue.

sudo npm cache clean -f

sudo npm install -g n install n 

sudo n stable 

The first command will force clean the npm package manager's cache, After the second and third commands, a stable version of the node and npm will be installed. then you can execute npm i and npm run build for creating an optimized production build.

This solution worked for the same error on the npm run build command in nextjs.

Aalok kumar
  • 309
  • 2
  • 5
0

I had the same error code when I was running npm run build inside node docker container.

Locally it was working while inside a container I had set option to throw error when there is a warning during compilation while locally it wasn't set. So this error can mean anything that is connected with stopping the process being done by NPM

MateuszK
  • 1
  • 1
0

In my case I generated a similar error when I copied the project over from another directory. some hidden files, like the critical .babelrc, were missing. SO ahhh... make sure you copy all the files! :)

Gil Hiram
  • 492
  • 5
  • 13
0

For me it was a ternary statement:

It was complaining about this line in particular, about the semicolon:

let num_coin = val.num_coin ? val.num_coin || 2;

I changed it to:

let num_coin = val.num_coin || 2;
Justin
  • 945
  • 12
  • 26
  • 1
    your ternary is incorrect, instead of || you need a colon: `let num_coin = val.num_coin ? val.num_coin : 2;` that being said, since you're just checking for truthyness of the val.num_coin, the second option is more concise – Justin Kruse Sep 04 '20 at 21:23
0

Likewise, I saw this error as a result of too little RAM. I cranked up the RAM on the VM and the error disappeared.

0

I found the solution here - https://javahowtos.com/guides/124-docker/418-npm-exit-status-137-when-building-a-docker-image.html

It says - The cause of this specific npm error status usually means that Docker is going out of memory. So, when this happens, the Linux kernel just kills the process.

  • Hi, the problem described here is not directly associated with docker, but your findings can be helpful for people encountering this issue while working with docker – captain hak Apr 02 '21 at 09:22
0

if you are running on ubuntu, please check your nodejs version. please update the version to the latest and clear the cache and reinstall the modules (npm install) and build.

or otherwise

please upgrade your RAM size and try again. it'll work sure.

Mafei
  • 3,063
  • 2
  • 15
  • 37