Skip to content
Latchkey
Node.js & npm

npm, yarn, and pnpm failures in CI - solved.

Resolve Node.js build failures in CI/CD: npm install errors, lockfile drift, peer dependency conflicts, registry timeouts, and out-of-memory builds. Practical fixes for npm, yarn, and pnpm.

Install & dependency resolution

ERESOLVE, peer deps, lockfile mismatches.

"configured to use yarn"Fix the Corepack "this project is configured to use yarn" error in CI by running the package manager named in "@swc/core platform binary missing"Fix "Failed to load native binding" / "Cannot find module '@swc/core-linux-x64-gnu'" in CI - the @swc/core "prebuilt binary not found for musl (alpine)"Fix "prebuilt binary not found for ... musl" on Alpine in CI - a native package ships glibc prebuilds only, "--omit=dev" missing toolFix builds that break after `npm ci --omit=dev` in CI - a compiler or bundler needed at build time lives in "Cannot read properties of null"Fix npm "Cannot read properties of null" engine errors in CI caused by a corrupted lockfile or cache, by "npm ERR! code EUNSUPPORTEDPROTOCOL"Fix npm "EUNSUPPORTEDPROTOCOL" in CI - a dependency uses a URL scheme (link:, portal:, catalog:, patch:) the "Invalid package name"Fix npm "Invalid package name" and "Invalid Version" errors in CI - a package.json whose name or version does "No workspaces found"Fix npm "No workspaces found" or "workspace <name> not found" in CI - a misdeclared workspaces glob, a "Tracker idealTree already exists"Fix npm "Tracker idealTree already exists" in CI - caused by two npm processes installing at once or a stale "package-lock.json … in sync"Fix "npm ci can only install with an existing package-lock.json … in sync with package.json" in CI - caused "EACCES: permission denied"Fix npm "EACCES: permission denied" errors on ~/.npm or node_modules in CI and Docker - caused by files owned "npm WARN EBADENGINE"Fix "npm WARN EBADENGINE unsupported engine" in CI by matching the runner Node version to the engines field "Errors … in your package-lock.json"Fix npm lockfile verification errors in CI - "Errors were found in your package-lock.json, run npm install to "npm ERR! code ENOENT package.json"Fix "npm ERR! code ENOENT ... package.json" in CI when npm runs in a directory that has no package.json, "ERESOLVE unable to resolve dependency tree"Fix the npm ERESOLVE "unable to resolve dependency tree" error in CI by resolving the real peer version "lockfileVersion mismatch"Fix npm lockfileVersion mismatches in CI by aligning the npm version that reads the lockfile with the version optional dep skipped for platformFix npm installs where a platform-specific optional dependency is skipped in CI, then a build or runtime step "Permission denied" on binFix a package bin failing to run in CI - "Permission denied" because the bin file lost its executable bit, postinstall blocked by policyFix breakage when an org-wide ignore-scripts policy blocks postinstall in CI - packages that download "working directory not clean"Fix npm version failing in CI - "Git working directory not clean" or git tag creation errors when npm version "ERR_PNPM_UNEXPECTED_STORE"Fix pnpm "ERR_PNPM_UNEXPECTED_STORE: Unexpected store location" in CI - node_modules was created against a "ERR_PNPM_LOCKFILE_BREAKING_CHANGE"Fix pnpm ERR_PNPM_LOCKFILE_BREAKING_CHANGE in CI - the committed pnpm-lock.yaml uses a format version the "ERR_PNPM_OUTDATED_LOCKFILE"Fix ERR_PNPM_OUTDATED_LOCKFILE in CI by regenerating and committing pnpm-lock.yaml, since pnpm install ERR_PNPM_PEER_DEP_ISSUESFix pnpm ERR_PNPM_PEER_DEP_ISSUES "Unmet peer dependencies" in CI - pnpm’s strict peer checking failing the "lockfile needs to be updated"Fix yarn install --frozen-lockfile failures in CI when the lockfile is out of date, by regenerating and "Integrity check failed"Fix yarn "Integrity check failed for …" / checksum mismatch in CI - a fetched package whose hash does not "Integrity check failed"Fix yarn integrity check failures in CI by clearing the yarn cache and reconciling yarn.lock when an "lockfile needs to be updated"Fix yarn "Your lockfile needs to be updated" under --frozen-lockfile / --immutable in CI - package.json Yarn enableScripts falseFix Yarn Berry leaving native packages half-installed in CI - enableScripts:false (or a per-package setting)

Registry & network

Timeouts, 5xx, auth, and proxy errors.

"corepack enable" EACCESFix "corepack enable" failing with EACCES in CI/Docker - Corepack cannot write yarn/pnpm shims into a Node "punycode … deprecated"Fix the Node "[DEP0040] The punycode module is deprecated" warning in CI - noisy on Node 21+ from a "self signed certificate in chain"Fix Node.js / npm "self signed certificate in certificate chain" in CI - caused by a TLS-intercepting proxy. "unable to verify the first certificate"Fix Node.js / npm "unable to verify the first certificate" (UNABLE_TO_VERIFY_LEAF_SIGNATURE) in CI - a server _authToken not expandedFix npm .npmrc _authToken auth failures in CI - a ${NPM_TOKEN} placeholder left literal because the env var "_authToken not configured"Configure the npm .npmrc auth token in CI so private installs authenticate, injecting the token from a secret "npm error code E403"Fix npm "E403 403 Forbidden" while installing in CI - a registry or proxy refusing a read your token is not "404 Not Found - GET"Fix npm "404 Not Found - GET https://registry…/@scope/pkg" in CI for a private package - wrong registry, "self signed certificate in chain"Fix npm "self signed certificate in chain" errors in CI by trusting the corporate CA properly instead of "npm warn config"Fix npm "npm warn config … is deprecated" noise in CI - old .npmrc keys (e.g. "403 Forbidden (publish)"Fix npm 403 Forbidden errors when publishing in CI, caused by a bad token, a taken name, a missing version "npm error code ENOTFOUND"Fix npm ENOTFOUND "getaddrinfo ENOTFOUND registry.npmjs.org" in CI - a DNS resolution failure reaching the ERR_PNPM_FETCH_404Fix pnpm ERR_PNPM_FETCH_404 "GET https://…: Not Found - 404" in CI - a package or version pnpm cannot fetch "unexpected error … ENOENT"Fix yarn "An unexpected error occurred: ENOENT: no such file or directory" in CI - a missing file/directory

Build & memory

Heap OOM, native modules, and toolchain gaps.

"Module not found: Can't resolve"Fix "Module not found: Error: Can't resolve 'X'" in Angular CI builds - a webpack import path points at a "Dynamic require of X is not supported"Fix esbuild "Dynamic require of 'fs' is not supported" in CI - a CommonJS module was bundled to ESM and its "--experimental-vm-modules"Fix Jest failing on ESM in CI - running ESM test files needs Node’s --experimental-vm-modules flag. "Cannot find module 'node:crypto'"Fix "Cannot find module 'node:crypto'" (or other node: builtins) in CI - code uses the node:-prefixed import "ERR_MODULE_NOT_FOUND"Fix Node ERR_MODULE_NOT_FOUND in CI - an ESM import that fails because the path is missing its file extension "ERR_REQUIRE_ESM"Fix Node ERR_REQUIRE_ESM "require() of ES Module not supported" in CI - a CommonJS require of an ESM-only "__dirname is not defined"Fix ReferenceError "__dirname is not defined in ES module scope" in CI - the CommonJS path globals do not "Cannot find module 'node-fetch'"Fix node-fetch import failures in CI - node-fetch v3 is ESM-only, so require() of it from CommonJS throws or "Must use import to load ES Module"Fix ERR_REQUIRE_ESM "Must use import to load ES Module" in CI - a CommonJS file called require() on a "read ECONNRESET"Fix "Error: read ECONNRESET" in CI HTTP tests - the peer reset the TCP connection mid-read, usually a "TypeError: fetch failed"Fix "TypeError: fetch failed" from Node's built-in undici fetch in CI - a low-level network, DNS, or TLS "ERR_INVALID_ARG_TYPE"Fix Node.js ERR_INVALID_ARG_TYPE "The \"path\" argument must be of type string. "ERR_OSSL_EVP_UNSUPPORTED"Fix Node.js ERR_OSSL_EVP_UNSUPPORTED "error:0308010C:digital envelope routines::unsupported" in CI - OpenSSL "is not defined by exports"Fix Node.js ERR_PACKAGE_PATH_NOT_EXPORTED "No exports main / subpath … is not defined" in CI - a deep import "ERR_WORKER_OUT_OF_MEMORY"Fix Node.js ERR_WORKER_OUT_OF_MEMORY "Worker terminated due to reaching memory limit" in CI - a worker’s "ERR_MODULE_NOT_FOUND"Fix Node.js ESM "ERR_MODULE_NOT_FOUND" caused by extensionless relative imports - native ESM requires the .js "ENOTEMPTY … rename"Fix npm "ENOTEMPTY: directory not empty, rename" in CI - npm failed to atomically move a staged package over "EROFS: read-only file system"Fix npm "EROFS: read-only file system" in CI/Docker - npm tried to write (cache, node_modules, prefix) to a package types not foundFix TypeScript failing to resolve a dependency’s types in CI - a package "exports" map missing a "types"

Scripts & lifecycle

ELIFECYCLE, exit codes, and hook failures.

"concurrently" command failedFix concurrently failing in CI - "concurrently: not found", or one parallel command exiting non-zero failing "husky … command not found"Fix husky hooks failing with "command not found" in CI - a tool invoked by a hook is not on PATH, or the hook "ERR_OSSL_EVP_UNSUPPORTED"Fix "error:0308010C digital envelope routines::unsupported" (ERR_OSSL) in npm builds on Node 17+ by upgrading "no tests found"Fix Node.js built-in test runner finding no tests in CI - node --test using its default file patterns, or the "node: bad option"Fix the Node.js "bad option" unknown-flag error in CI by removing the flag, fixing its spelling, or using a "Cannot use import statement outside a module"Fix the Node.js "SyntaxError: Cannot use import statement outside a module" in CI by telling Node to treat "Error: Dynamic require of 'X' is not supported"Fix the "Dynamic require of X is not supported" error from bundled ESM in CI by bundling for CommonJS or "ENOENT: no such file or directory, open"Fix the Node.js "ENOENT: no such file or directory, open" error in CI by resolving paths against the right "Error: write EPIPE"Fix the Node.js "Error: write EPIPE" in CI by handling the stream error when a downstream reader closes the "Error: spawn X ENOENT"Fix the Node.js "spawn ENOENT" child-process error in CI by installing the missing executable or correcting "Error [ERR_INTERNAL_ASSERTION]"Diagnose the Node.js ERR_INTERNAL_ASSERTION error in CI by upgrading Node, removing the misbehaving native "TypeError [ERR_INVALID_ARG_TYPE]"Fix the Node.js ERR_INVALID_ARG_TYPE error in CI by passing the argument type a core API expects instead of "Error [ERR_PACKAGE_PATH_NOT_EXPORTED]"Fix the Node.js ERR_PACKAGE_PATH_NOT_EXPORTED error in CI by importing a subpath the package exports map "Error [ERR_REQUIRE_ESM]: require() of ES Module"Fix the Node.js ERR_REQUIRE_ESM error in CI by switching to a dynamic import, pinning a CommonJS-compatible "Error [ERR_UNSUPPORTED_DIR_IMPORT]"Fix the Node.js ERR_UNSUPPORTED_DIR_IMPORT error in CI by importing an explicit file path instead of a "UnhandledPromiseRejection"Fix Node.js UnhandledPromiseRejection crashes in CI by awaiting or catching the rejecting promise so the "--unhandled-rejections"Understand Node.js --unhandled-rejections modes (throw/strict/warn/none) - why a job that used to warn now "cross-env: command not found"Fix "cross-env: command not found" in CI - the cross-env binary is missing because devDependencies were "MaxListenersExceededWarning"Fix Node.js "MaxListenersExceededWarning: Possible EventEmitter memory leak detected" in CI - the warning pre/post hook failsFix surprising CI failures from npm pre/post lifecycle scripts - a failing `pre<x>`/`post<x>` hook fails the "[rollup] Could not resolve"Fix Rollup "Could not resolve" during a Vite build in CI - an import has no installed package and is not "Command failed with exit code 1"Understand yarn "error Command failed with exit code 1" in CI - it is a wrapper around a script that failed.
Explore other topics