This error occurs when you run an npm workspace command with a filter that doesn't match any workspace in your monorepo. It typically happens due to package name mismatches between what you specify with --workspace and what's configured in package.json files.
The ENOWORKSPACES error indicates that npm couldn't find any workspace packages matching your filter criteria. This typically occurs when you specify a workspace name with --workspace that doesn't match the name field in any package.json, or when you're running a command that doesn't support workspaces.
Check the exact package names configured in your monorepo. Look at the 'name' field in each workspace's package.json:
{
"name": "@mycompany/my-package",
"version": "1.0.0"
}Note the full package name including any @scope prefix.
Use the exact package name from package.json, not the folder name:
# WRONG - using folder name
npm run build --workspace=my-package
# CORRECT - using the name field
npm run build --workspace=@mycompany/my-packageCheck what workspaces npm recognizes:
cat package.json | grep -A 5 '"workspaces"'Then check each workspace's package.json name field.
You can use --workspace with a directory path:
# Target a specific directory
npm run build --workspace packages/app
# Run in ALL workspaces
npm run build --workspacesNote: Use --workspaces (plural) to run in all workspaces.
Some npm commands don't support workspaces. Use --no-workspaces:
npm config list --no-workspacesIf not all workspaces have the same npm script, use --if-present:
npm run test --workspaces --if-presentThis skips workspaces without the target script.
The ENOWORKSPACES error is fundamentally a filter matching issue. npm uses exact string matching on the 'name' field from package.json filesโit does not support glob patterns or fuzzy matching. When you use --workspace, npm reads your root package.json workspaces array to find workspace directories, then reads each workspace's package.json to get its name. Your filter must match one of those names exactly.
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