How to fix npm ERR! code ENOWORKSPACES npm ERR! No workspaces matched the filter in npm

npmBEGINNERMEDIUMUpdated Dec 3, 2025· 162 views

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"
}
  1. Verify your workspace package names
  2. Use the correct package name in --workspace flag
  3. List all available workspaces
  4. Filter by directory path if needed
npm — error
{
"name": "@mycompany/my-package",
"version": "1.0.0"
}
npm ERR! code ENOWORKSPACES
npm 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

  1. Using folder name instead of package name in --workspace flag
  2. Mismatch between the 'name' field in workspace package.json and the directory name
  3. Running commands that don't support workspaces (like npm config) with workspace filters
  4. Typo in workspace package name or incorrect scope prefix
  5. 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"

1Verify your workspace package names

Check the exact package names configured in your monorepo. Look at the 'name' field in each workspace's package.json:

json
{
  "name": "@mycompany/my-package",
  "version": "1.0.0"
}

Note the full package name including any @scope prefix.

2Use the correct package name in --workspace flag

Use the exact package name from package.json, not the folder name:

bash
# WRONG - using folder name
npm run build --workspace=my-package

# CORRECT - using the name field
npm run build --workspace=@mycompany/my-package
3List all available workspaces

Check what workspaces npm recognizes:

bash
cat package.json | grep -A 5 '"workspaces"'

Then check each workspace's package.json name field.

4Filter by directory path if needed

You can use --workspace with a directory path:

bash
# Target a specific directory
npm run build --workspace packages/app

# Run in ALL workspaces
npm run build --workspaces

Note: Use --workspaces (plural) to run in all workspaces.

5For unsupported commands, use --no-workspaces flag

Some npm commands don't support workspaces. Use --no-workspaces:

bash
npm config list --no-workspaces
6Use --if-present for inconsistent scripts

If not all workspaces have the same npm script, use --if-present:

bash
npm run test --workspaces --if-present

This 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