How to fix npm ERR! code ENOWORKSPACES npm ERR! No workspaces found in npm

npmBEGINNERMEDIUMUpdated Dec 7, 2025· 217 views

This error occurs when npm expects workspaces but none are configured. Usually caused by running workspace commands without a workspaces field in package.json, or running from the wrong directory.

Quick fix

Fixes npm ERR! code ENOWORKSPACES npm ERR! No workspaces found

{
  "name": "my-monorepo",
  "private": true,
  "workspaces": [
    "packages/*"
  ]
}
  1. Add workspaces configuration
  2. Run commands from the root directory
  3. Check for global workspaces setting
  4. Use --no-workspaces for unsupported commands
npm — error
{
"name": "my-monorepo",
"private": true,
"workspaces": [
"packages/*"
]
}
npm ERR! code ENOWORKSPACES
npm ERR! No workspaces found

What this error means

The ENOWORKSPACES error means npm is looking for workspace configuration but can't find any. This happens when: - You're running a workspace-aware command but your package.json doesn't have a `workspaces` field - You're running npm from a subdirectory instead of the monorepo root - You have `workspaces=true` set globally in .npmrc but the project isn't a workspace - Using npm commands that don't support workspaces (like certain `npm config` operations in npm 9.3+) npm workspaces require npm 7+ and a properly configured root package.json.

Typical symptoms

  • npm commands fail with 'No workspaces found'
  • Error code ENOWORKSPACES
  • Workspace commands like 'npm run -ws' fail
  • Works in some directories but not others

Common causes

  1. Missing 'workspaces' field in root package.json
  2. Running npm from subdirectory instead of monorepo root
  3. Global workspaces=true in .npmrc affecting non-workspace projects
  4. Using workspace flags with commands that don't support them
  5. npm version < 7 which doesn't support workspaces

How to fix "npm ERR! code ENOWORKSPACES npm ERR! No workspaces found"

1Add workspaces configuration

If you're setting up a monorepo, add the workspaces field to your root package.json:

json
{
  "name": "my-monorepo",
  "private": true,
  "workspaces": [
    "packages/*"
  ]
}

Common patterns:
- "packages/*" - all directories in packages/
- "apps/*" - all directories in apps/
- ["packages/*", "apps/*"] - multiple directories

2Run commands from the root directory

Workspace commands must run from the monorepo root:

bash
# Wrong: running from subdirectory
cd packages/my-package
npm run build  # May fail with ENOWORKSPACES

# Correct: run from root with workspace flag
cd /path/to/monorepo-root
npm run build --workspace=my-package
# or
npm run build -w my-package
3Check for global workspaces setting

You might have workspaces enabled globally in .npmrc:

bash
# Check your .npmrc
cat ~/.npmrc

# If you see workspaces=true, remove it
npm config delete workspaces --location=user

This setting forces all projects to be treated as workspaces.

4Use --no-workspaces for unsupported commands

Some npm commands don't support workspaces. Use the flag to skip workspace processing:

bash
npm config list --no-workspaces
npm config get registry --no-workspaces
5Check npm version

Workspaces require npm 7 or later:

bash
npm --version

# If below 7, upgrade npm
npm install -g npm@latest

Advanced notes

npm 9.3+ breaking change: Starting with npm 9.3.0, some commands that don't support workspaces throw ENOWORKSPACES instead of silently ignoring the flag. Use --no-workspaces explicitly.

Workspace initialization: Create a new workspace package properly:

bash
npm init -w ./packages/new-package

This creates the directory and updates the root package.json automatically.

Next.js/Turborepo gotcha: Some frameworks have their own workspace detection that can conflict with npm. If using Turborepo, ensure you're running commands through turbo not directly with npm.

Lerna migration: If migrating from Lerna to npm workspaces, ensure you've added the workspaces field—Lerna used lerna.json which npm doesn't read.

Frequently asked questions

What does "npm ERR! code ENOWORKSPACES npm ERR! No workspaces found" mean?
The ENOWORKSPACES error means npm is looking for workspace configuration but can't find any. json.
How do I fix "npm ERR! code ENOWORKSPACES npm ERR! No workspaces found"?
This error occurs when npm expects workspaces but none are configured. Usually caused by running workspace commands without a workspaces field in package.json, or running from the wrong directory.
What causes "npm ERR! code ENOWORKSPACES npm ERR! No workspaces found"?
Missing 'workspaces' field in root package.json Running npm from subdirectory instead of monorepo root Global workspaces=true in .npmrc affecting non-workspace projects
Is the "npm ERR! code ENOWORKSPACES npm ERR! No workspaces found" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading