The EWORKSPACEMISSING error occurs when npm cannot find a workspace referenced in your monorepo configuration. This happens when a workspace is defined in package.json but the directory doesn't exist or the package name doesn't match.
npm workspaces allow you to manage multiple packages in a single repository (monorepo). The EWORKSPACEMISSING error means that your root package.json declares a workspace that npm cannot locate. This typically occurs when the directory specified in the workspaces array doesn't exist on disk, the package name you're trying to reference doesn't match the actual package.json name inside the workspace, you're using a glob pattern that doesn't match any directories, or a workspace directory was deleted but the configuration wasn't updated. This prevents npm from properly linking workspace dependencies, which breaks commands like npm install, npm run, and other workspace-aware operations.
Open your root package.json and check the workspaces field. Make sure the paths or glob patterns are correctly defined:
{
"name": "my-monorepo",
"workspaces": [
"packages/*",
"apps/web",
"tools/cli"
]
}Common valid patterns:
- "packages/*" - all folders inside packages/
- "packages/core" - specific folder
- ["packages/*", "apps/*"] - multiple patterns
Run this command to verify the directories actually exist on disk:
ls -la packages/
ls -la apps/If directories listed in package.json don't appear in the output, you need to either:
- Create the missing directories with mkdir -p packages/missing-workspace
- Update package.json to remove references to deleted directories
- Restore the missing directories from version control
When using the -w flag, you must use the actual package name from each workspace's package.json, not the folder name. For example:
# Inside packages/my-app/package.json, if "name" is "@myorg/my-app"
# Use this command:
npm install -w @myorg/my-app
# NOT this (wrong - uses folder name):
npm install -w my-appTo find the correct package names, check each workspace's package.json:
cat packages/*/package.json | grep '"name"'Once you've corrected the configuration, clean up and reinstall:
rm -rf node_modules package-lock.json
rm -rf packages/*/node_modules
# Reinstall from root
cd /path/to/root
npm installThis rebuilds symlinks between workspace packages and ensures npm recognizes all workspaces correctly.
If you're using Turborepo or other monorepo tools, they have additional validation on top of npm workspaces. Turborepo explicitly requires npm workspaces to be defined in the root package.json. For pnpm or Yarn users, the configuration differs - pnpm uses pnpm-workspace.yaml and Yarn has its own workspace syntax. Package scopes (e.g., @myorg/package) are common in monorepos to avoid name conflicts. The package.json name field is what npm uses internally, not the folder name.
npm ERR! code E401 npm ERR! 401 Unauthorized - Token has expired
Token has expired - npm authentication failure
npm ERR! code EAI_NODATA npm ERR! errno EAI_NODATA npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org
How to fix "npm ERR! code EAI_NODATA - getaddrinfo EAI_NODATA"
npm ERR! code EMPTYPACKAGE npm ERR! Package contains no files
How to fix 'npm ERR! code EMPTYPACKAGE' - Package contains no files
npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Address not available
How to fix "npm ERR! code EADDRNOTAVAIL - Address not available" error
npm ERR! code CERT_SIGNATURE_FAILURE npm ERR! Certificate signature failure
How to fix 'npm ERR! code CERT_SIGNATURE_FAILURE' certificate signature failure