How to fix npm ERR! code ENOWORKSPACES npm ERR! No workspaces matched the filter in npm
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.
Quick fix
Fixes ENOWORKSPACES
{
"name": "@mycompany/my-package",
"version": "1.0.0"
}- Verify your workspace package names
- Use the correct package name in --workspace flag
- List all available workspaces
- Filter by directory path if needed
{"name": "@mycompany/my-package","version": "1.0.0"}npm ERR! code ENOWORKSPACESnpm ERR! No workspaces matched the filter
What this error means
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.
Typical symptoms
- npm command fails with ENOWORKSPACES error code
- Error message shows 'No workspaces matched the filter'
- Command works when run from root but fails with --workspace flag
- Other team members' monorepo commands work but yours don't
- Workspace-related commands fail even though the folder exists
Common causes
- Using folder name instead of package name in --workspace flag
- Mismatch between the 'name' field in workspace package.json and the directory name
- Running commands that don't support workspaces (like npm config) with workspace filters
- Typo in workspace package name or incorrect scope prefix
- Using glob patterns with --workspace (npm doesn't support glob syntax)
How to fix "npm ERR! code ENOWORKSPACES npm ERR! No workspaces matched the filter"
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.
Advanced notes
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.
Frequently asked questions
- What does "ENOWORKSPACES" mean?
- The ENOWORKSPACES error indicates that npm couldn't find any workspace packages matching your filter criteria. json, or when you're running a command that doesn't support workspaces.
- How do I fix "ENOWORKSPACES"?
- 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.
- What causes "ENOWORKSPACES"?
- Using folder name instead of package name in --workspace flag Mismatch between the 'name' field in workspace package.json and the directory name Running commands that don't support workspaces (like npm config) with workspace filters
- Is the "ENOWORKSPACES" error serious?
- It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- 📚npm Official Documentation
- 📖npm Docs: Workspace Filters(Official Docs)
- 📖npm Docs: npm Workspaces(Official Docs)
- 💬Stack Overflow: Workspace Filtering(Stack Overflow)