Home·Error messages

npm · npm

The message

npm ERR! code ELIFECYCLE

What it means

A script in package.json exited with a non-zero code — ELIFECYCLE is npm's wrapper around that, not the cause. The cause is whatever your build or test script did, and the real error lines sit above this one. Scroll up to the first error, or run the actual command printed after npm ERR! <pkg>@<ver> <script>: by hand to see its output without npm's wrapper around it. The exit code that follows tells you a little too: 1 is a plain failure, while 137 means the process was killed, typically for memory.

The fix

There is no one-line command for this. The explanation says what to look at instead.

Printed by
npm
npm
20

With npm the cause sits in the first code XXXX line rather than the last six npm ERR! lines, and when the failure comes from the dependency tree or a native build instead of your own code, deleting node_modules and installing again clears about half of them.

Reading an error message

  • Read from the first line down. The lower you go the more it is about the tool’s internals; the cause is usually at the top.
  • If there is a file and a line number, start there — not the top stack frame, but the topmost line that names a file you wrote.
  • Search the message verbatim, but strip your own paths and variable names first; those are what stop the search from matching.
  • The same condition is worded differently across tool versions. If results look wrong, add the version number to the query.
  • Before pasting a fix, check what it throws away. Some of these cannot be undone.

Common questions

Q. What does “npm ERR! code ELIFECYCLE” mean?

A script in package.json exited with a non-zero code — ELIFECYCLE is npm's wrapper around that, not the cause. The cause is whatever your build or test script did, and the real error lines sit above this one. Scroll up to the first error, or run the actual command printed after npm ERR! <pkg>@<ver> <script>: by hand to see its output without npm's wrapper around it. The exit code that follows tells you a little too: 1 is a plain failure, while 137 means the process was killed, typically for memory.

Q. How do I fix it?

There is no one-line command. The explanation above says what to look at instead.

Q. Which tool prints this?

npm. It sits under npm, and the message runs to 4 words.

Errors nearby