Error Knowledge Base npm ELIFECYCLE

npm ERR! code ELIFECYCLE

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

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.

1. Confirm this is your error
npm ERR! code ELIFECYCLE
npm ERR! Exit status 1
npm ERR! command failed
2. Check the cause
npm pkg get scripts
node -v
npm -v
npm install --foreground-scripts
3. Apply the safe fix
# Re-run the failing script directly so the real error is easier to see.
npm run <script> -- --verbose

# If it fails during install scripts, run install with foreground script output.
npm install --foreground-scripts
4. Verify it works
npm run <script>
npm install
Don't use unsafe shortcuts
  • Do not fix only the ELIFECYCLE line, scroll up to the first script error.
  • Do not skip scripts permanently unless you know the package does not need its install or build step.
  • Do not assume npm itself is broken before checking missing tools like Python, make, or a compiler.

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