npm ENOLOCAL "Could not install from … as it does not contain a package.json"
ENOLOCAL means npm interpreted a dependency as a local filesystem path and found no valid package there. It happens with file: dependencies, or when a spec is mistaken for a path.
What this error means
npm install fails with npm error code ENOLOCAL, saying it could not install from a path because it does not contain a package.json (or the path does not exist). The path in the message is the clue.
npm error code ENOLOCAL
npm error Could not install from "packages/ui" as it does not
npm error contain a package.json file.Common causes
A file: dependency pointing at the wrong path
A "dep": "file:../packages/ui" (or a workspace path) that does not exist or has no package.json in CI’s checkout makes npm fail with ENOLOCAL.
A spec misread as a local path
An argument that looks like a path (contains a slash, or starts with ./) is treated as a local install target rather than a registry package.
How to fix it
Fix the local path or use a registry spec
Make the path real and contain a package.json, or install from the registry instead.
# ensure the local package exists and has a package.json
ls packages/ui/package.json
# or install the registry package explicitly
npm install @acme/ui@^1.0.0Verify checkout and workspace layout
- Confirm CI checks out the directory the
file:dependency points to. - For monorepos, ensure workspace paths resolve from the repo root.
- Avoid passing package names that look like paths.
How to prevent it
- Keep
file:paths valid and checked out in CI. - Prefer workspace protocols/registry specs over raw paths where possible.
- Verify the monorepo layout matches the dependency paths.