How to fix npm ERR! code ENOENT npm ERR! Missing workspace package: packages/package-name in npm

npmBEGINNERMEDIUMUpdated Dec 5, 2025ยท 222 views

This error occurs when npm can't find a workspace directory that's declared in your package.json. Usually caused by a typo in the workspaces glob, a deleted directory, or mismatched paths.

Quick fix

Fixes npm ERR! code ENOENT npm ERR! Missing workspace package: packages/package-name

# List your packages directory
ls -la packages/

# Check if the specific package exists
ls -la packages/package-name
  1. Verify the workspace directory exists
  2. Check your workspaces configuration
  3. Create the missing workspace
  4. Ensure each workspace has package.json
npm โ€” error
# List your packages directory
ls -la packages/
# Check if the specific package exists
ls -la packages/package-name
npm ERR! code ENOENT
npm ERR! Missing workspace package: packages/package-name

What this error means

The "Missing workspace package" error (ENOENT) means your package.json declares workspaces that don't exist on the filesystem. npm reads the `workspaces` array, tries to find each matching directory, and fails when a path doesn't exist. This commonly happens when: - There's a typo in the workspace path or glob pattern - A workspace package was deleted but not removed from the config - The directory exists but doesn't contain a package.json - You're using a glob that doesn't match your directory structure

Typical symptoms

  • npm install fails with 'Missing workspace package'
  • Error shows specific path like 'packages/package-name'
  • ENOENT error during workspace initialization
  • Works after removing certain workspace paths

Common causes

  1. Typo in workspaces path or glob pattern in package.json
  2. Workspace directory was deleted or moved
  3. Directory exists but missing package.json inside it
  4. Git didn't clone empty directories
  5. Glob pattern doesn't match actual directory structure

How to fix "npm ERR! code ENOENT npm ERR! Missing workspace package: packages/package-name"

1Verify the workspace directory exists

Check if the missing directory actually exists:

bash
# List your packages directory
ls -la packages/

# Check if the specific package exists
ls -la packages/package-name

If the directory doesn't exist, either create it or remove it from workspaces config.

2Check your workspaces configuration

Verify the paths in your root package.json:

json
{
  "workspaces": [
    "packages/*"
  ]
}

Common mistakes:
- "packages" instead of "packages/*" (missing glob)
- "package/*" instead of "packages/*" (typo)
- Listing a specific package that doesn't exist

3Create the missing workspace

If you need to create the workspace:

bash
# Create workspace with npm init
npm init -w ./packages/package-name

# This creates the directory AND a package.json inside it

Or manually:

bash
mkdir -p packages/package-name
cd packages/package-name
npm init -y
4Ensure each workspace has package.json

Every workspace directory must contain a valid package.json:

bash
# Check for missing package.json files
for dir in packages/*/; do
  if [ ! -f "$dir/package.json" ]; then
    echo "Missing package.json in $dir"
  fi
done

Create missing package.json files:

bash
cd packages/missing-package
npm init -y
5Remove deleted workspaces from config

If the workspace was intentionally deleted, remove it from package.json:

json
{
  "workspaces": [
    "packages/core",
    "packages/cli"
  ]
}

Then clean and reinstall:

bash
rm -rf node_modules package-lock.json
npm install

Advanced notes

Empty directories in Git: Git doesn't track empty directories. If a workspace was added but never had files committed, cloning the repo won't create that directory. Use a .gitkeep file:

bash
touch packages/new-workspace/.gitkeep

Glob debugging: Test what your glob pattern matches:

bash
# See what packages/* would match
ls -d packages/*

Package name vs directory name: The workspace is identified by its directory path, not the name in its package.json. packages/my-app must exist even if package.json says "name": "@scope/my-app".

Symlinks: If workspaces are symlinked, ensure the symlink target exists. Use ls -la to see where symlinks point.

Frequently asked questions

What does "npm ERR! code ENOENT npm ERR! Missing workspace package: packages/pack" mean?
json declares workspaces that don't exist on the filesystem. npm reads the workspaces array, tries to find each matching directory, and fails when a path doesn't exist.
How do I fix "npm ERR! code ENOENT npm ERR! Missing workspace package: packages/pack"?
This error occurs when npm can't find a workspace directory that's declared in your package.json. Usually caused by a typo in the workspaces glob, a deleted directory, or mismatched paths.
What causes "npm ERR! code ENOENT npm ERR! Missing workspace package: packages/pack"?
Typo in workspaces path or glob pattern in package.json Workspace directory was deleted or moved Directory exists but missing package.json inside it
Is the "npm ERR! code ENOENT npm ERR! Missing workspace package: packages/pack" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading