npm
npm Error Codes
Error codes thrown by the npm CLI and Node package manager. These appear as the code property on errors and in npm's error output.
24 codes
· All codes 24 codes
- E403 Forbidden The registry rejected the request because the authenticated user lacks permission for the package or version, or because a dependency is blocked by a security/license policy. Check that you're logged in to the right account with npm whoami, and that the configured registry (see .npmrc) is the one you intend to use.
- E404 Package Not Found The requested package does not exist in the registry. Verify the package name is spelled correctly and that you are pointing at the right registry (check .npmrc or the --registry flag).
- EACCES Permission Denied npm lacks permission to write to a directory, commonly the global node_modules or npm cache. Fix the directory ownership rather than using sudo: see the npm docs on fixing permissions. Using sudo with npm is generally discouraged.
- EAUDIT Audit Security Vulnerability npm audit found security vulnerabilities in the dependency tree. Review the report with npm audit and apply fixes with npm audit fix. Critical vulnerabilities block install when audit-level is set.
- EBADENGINE Incompatible Engine The installed Node.js or npm version does not satisfy the engines field required by a package. Upgrade Node.js/npm to a compatible version, or use a version manager such as nvm or fnm.
- ECONNREFUSED Connection Refused npm could not connect to the registry. The registry may be down, unreachable, or behind a proxy. Check your network connection and proxy settings (npm config get proxy).
- ECONNRESET Connection Reset The TCP connection to the npm registry was forcibly closed by the remote server mid-transfer. Usually transient — retry the command. If it recurs, check for proxy or firewall interference, or try switching registries.
- EEXIST File Already Exists npm tried to create a file or directory at a path that already exists, often a leftover from an interrupted install, a stale cache entry, or a broken symlink. Remove the conflicting file or directory and retry, or pass --force to overwrite it.
- EINTEGRITY Integrity Checksum Mismatch The downloaded package content does not match the integrity hash recorded in package-lock.json. This can indicate a corrupted download or a tampered registry. Run npm cache clean --force and reinstall.
- EINVALIDPACKAGENAME Invalid Package Name The package name in package.json or specified on the command line does not conform to npm naming rules. Names must be lowercase, URL-safe, and not start with a dot or underscore.
- EJSONPARSE JSON Parse Error npm could not parse a JSON file, most commonly package.json or package-lock.json. Use a JSON linter to find the syntax error in the indicated file.
- ELIFECYCLE Lifecycle Script Failed A lifecycle script (install, build, test, etc.) exited with a non-zero status. The error output above this message shows the actual failure. Run the script directly to debug.
- ENEEDAUTH Authentication Required The registry requires authentication for this operation. Run npm login to authenticate, or provide an auth token in .npmrc for private registries.
- ENOENT No Such File Or Directory npm cannot find a required file or directory, most commonly package.json in the current working directory. Run npm commands from the project root, or run 'npm init' to create a package.json.
- ENOLOCK No Lockfile The operation requires a package-lock.json or npm-shrinkwrap.json but none was found. Run npm install to generate one, or use npm install --package-lock to force creation.
- ENOSELF Cannot Install Self A package is trying to install itself as its own dependency, which creates a circular dependency. Check package.json dependencies for a package with the same name as the current project.
- ENOSPC No Space Left on Device The filesystem ran out of space during package extraction or cache writing. Free disk space and retry. The npm cache can be cleared with npm cache clean --force.
- ENOTFOUND Registry Host Not Found npm could not resolve the registry hostname via DNS. Check your internet connection, verify that the configured registry URL is correct ('npm config get registry'), and ensure no firewall or proxy is blocking outbound connections.
- EOTP One-Time Password Required The registry requires a one-time password because two-factor authentication is enabled on the account, typically when running npm publish or changing account settings. Pass the current authenticator code with --otp=<code>, or use an automation token to bypass OTP prompts in CI.
- EPERM Operation Not Permitted npm's underlying filesystem call (often rename, unlink, or mkdir) was rejected by the operating system, most commonly on Windows when a file is locked by another process such as an editor, antivirus scanner, or running dev server. Close programs that may be holding a lock on the path, retry, or run as Administrator/root as a last resort.
- ERESOLVE Dependency Resolution Failure npm cannot resolve a dependency tree that satisfies all peer dependency constraints. Use npm install --legacy-peer-deps to bypass strict peer checks, or npm install --force as a last resort. Review the conflict described in the error output.
- EROFS Read-Only File System npm tried to write to a filesystem that is mounted read-only, commonly inside a Docker container, a read-only Kubernetes root filesystem, or a virtualized filesystem that doesn't support symlinks. Mount a writable volume for the npm cache and project directory, or run the install step before switching the filesystem to read-only.
- ETARGET No Matching Version No published version of the package satisfies the requested semver range. Check the version specifier in package.json and compare against versions available via npm view <package> versions.
- ETIMEDOUT Connection Timed Out npm did not receive a response from the registry within the allowed time. Check your internet connection, proxy settings, or try increasing the timeout with '--fetch-timeout'. The registry may also be temporarily unavailable.