npm ERR! code ELIFECYCLE

npm returned ELIFECYCLE because a package lifecycle script like install, test, or build exited with a non-zero status.

npm ERR! code ELIFECYCLE
npm ERR! Exit status 1
npm ERR! command failed

Fix it fast

Most likely: A lifecycle script failed and ELIFECYCLE is npm's wrapper error. The real error is usually a few lines above it in the script output.

Confirm this is your error

Match the output and confirm you are troubleshooting the same failure.

npm ERR! code ELIFECYCLE
npm ERR! Exit status 1
npm ERR! command failed

What Broke in the Build

npm returned ELIFECYCLE because a package lifecycle script like install, test, or build exited with a non-zero status.

Find the first real build failure

Scroll up to the first error printed by the failing script. ELIFECYCLE is usually the wrapper error.

Re-run just the failing script for clearer output (example:npm run <script> -- --verbose).

Ensure required toolchain is installed (common:Python, C compiler toolchain, make).

If this is in CI, compare environment variables and build dependencies with local.

Find the first real build error

Print scripts with cat package.json | jq .scripts (or open package.json), and check toolchain availability with python --version, make --version, gcc --version (as applicable).

Why the Build Fails

Usually this comes down to a postinstall / install / prepare script failed due to missing toolchain or environment, a dependency build step failed (native addon compilation, missing Python, missing make, etc.), or the script itself is failing with an application error.

Prove the Build Path Is Clean

Re-run the failing script and confirm it exits 0, and re-run npm install and confirm the lifecycle error is gone.

Where the real build failure usually starts

npm runs lifecycle scripts defined by packages during install. If any script exits non-zero, npm surfaces ELIFECYCLE and stops the install.

Keep Build Prerequisites Consistent

To prevent this, keep build dependencies documented and installed on CI runners, avoid heavy install-time scripts when possible, prefer build steps in CI, and pin Node/npm versions so script behavior stays consistent.

Docs and source code

github.com/npm/cli/blob/39495d07b9a66c88621e8a2ad07739ee98b70a56/lib/utils/lifecycle.js

Open-source npm CLI code reference from v5.0.0 (legacy error code path). - GitHub

      er.message = pkg._id + ' ' + stage + ': `' + cmd + '`\n' +
                   er.message
      if (er.code !== 'EPERM') {
        er.code = 'ELIFECYCLE'
      }
      fs.stat(npm.dir, function (statError, d) {
        if (statError && statError.code === 'ENOENT' && npm.dir.split(path.sep).slice(-1)[0] === 'node_modules') {

Need help or found a mistake? Contact RepoFlow support for questions.

Join our mailing list

Product updates, new tools, and practical guides from RepoFlow.