npm looked for node_modules but it does not exist yet (fresh checkout, cleaned workspace, or wrong working directory). Install dependencies or point npm at the correct folder.
Fixes npm ERR! Error: ENOENT: no such file or directory, stat 'node_modules'
pwd
ls node_modules 2>/dev/nullpwdls node_modules 2>/dev/nullnpm ERR! Error: ENOENT: no such file or directory, stat 'node_modules'
On this page
npm expects node_modules to exist after installs and when resolving binaries. If you run scripts before installing dependencies, mount an empty volume over the project, or execute in the wrong directory, stat on node_modules fails with ENOENT. CI pipelines that clean workspaces, Docker bind mounts that shadow the folder, and monorepos with nested packages commonly see this when running npm run before npm install.
pwd
ls node_modules 2>/dev/nullnpm ci
# or
npm installEnsure your container workdir matches the project root and that you are not mounting an empty host folder over node_modules.
If using workspaces, run npm inside the specific package that owns node_modules or enable workspaces at the root.
npm run <script>CI best practice is npm ci after checkout and before running scripts; cache node_modules cautiously to avoid stale/empty mounts. Docker Compose often mounts the repo; build a layer that installs dependencies, or mount only source and keep node_modules inside the container image. With pnpm/yarn workspaces, node_modules may be hoisted—ensure your script runs where they are present.