This error occurs when npm can't find a workspace directory that's declared in your package.json. Usually caused by a typo in the workspaces glob, a deleted directory, or mismatched paths.
The "Missing workspace package" error (ENOENT) means your package.json declares workspaces that don't exist on the filesystem. npm reads the `workspaces` array, tries to find each matching directory, and fails when a path doesn't exist. This commonly happens when: - There's a typo in the workspace path or glob pattern - A workspace package was deleted but not removed from the config - The directory exists but doesn't contain a package.json - You're using a glob that doesn't match your directory structure
Check if the missing directory actually exists:
# List your packages directory
ls -la packages/
# Check if the specific package exists
ls -la packages/package-nameIf the directory doesn't exist, either create it or remove it from workspaces config.
Verify the paths in your root package.json:
{
"workspaces": [
"packages/*"
]
}Common mistakes:
- "packages" instead of "packages/*" (missing glob)
- "package/*" instead of "packages/*" (typo)
- Listing a specific package that doesn't exist
If you need to create the workspace:
# Create workspace with npm init
npm init -w ./packages/package-name
# This creates the directory AND a package.json inside itOr manually:
mkdir -p packages/package-name
cd packages/package-name
npm init -yEvery workspace directory must contain a valid package.json:
# Check for missing package.json files
for dir in packages/*/; do
if [ ! -f "$dir/package.json" ]; then
echo "Missing package.json in $dir"
fi
doneCreate missing package.json files:
cd packages/missing-package
npm init -yIf the workspace was intentionally deleted, remove it from package.json:
{
"workspaces": [
"packages/core",
"packages/cli"
]
}Then clean and reinstall:
rm -rf node_modules package-lock.json
npm installEmpty directories in Git: Git doesn't track empty directories. If a workspace was added but never had files committed, cloning the repo won't create that directory. Use a .gitkeep file:
touch packages/new-workspace/.gitkeepGlob debugging: Test what your glob pattern matches:
# See what packages/* would match
ls -d packages/*Package name vs directory name: The workspace is identified by its directory path, not the name in its package.json. packages/my-app must exist even if package.json says "name": "@scope/my-app".
Symlinks: If workspaces are symlinked, ensure the symlink target exists. Use ls -la to see where symlinks point.
npm ERR! code ENOAUDIT npm ERR! Audit endpoint not supported
How to fix "npm ERR! code ENOAUDIT - Audit endpoint not supported"
npm ERR! code EBADDEVENGINES npm ERR! devEngines.runtime incompatible with current node version
How to fix "npm ERR! code EBADDEVENGINES - devEngines.runtime incompatible with current node version"
npm ERR! code ETOOMANYARGS npm ERR! Too many arguments
How to fix "npm ERR! code ETOOMANYARGS - Too many arguments"
npm ERR! code EINVALIDTAGNAME npm ERR! Invalid tag name: tag names cannot contain spaces
How to fix "npm ERR! code EINVALIDTAGNAME - tag names cannot contain spaces"
npm ERR! code E400 npm ERR! 400 Bad Request
How to fix "npm ERR! code E400 - 400 Bad Request" error