How to fix npm ERR! code EDUPLICATEWORKSPACE npm ERR! must not have multiple workspaces with the same name in npm

npmINTERMEDIATEHIGHUpdated Dec 5, 2025ยท 137 views

This error occurs when your npm monorepo has multiple workspace packages with identical names in their package.json files. Each workspace must have a unique name value to avoid conflicts.

Quick fix

Fixes npm ERR! code EDUPLICATEWORKSPACE npm ERR! must not have multiple workspaces with the same name

find . -path ./node_modules -prune -o -name 'package.json' -type f -exec grep -H '"name"' {} \;
  1. Find all duplicate workspace package names
  2. Examine your root package.json workspaces configuration
  3. Rename duplicate workspace packages
  4. Clear npm cache and reinstall dependencies
npm โ€” error
find . -path ./node_modules -prune -o -name 'package.json' -type f -exec grep -H '"name"' {} \;
npm ERR! code EDUPLICATEWORKSPACE
npm ERR! must not have multiple workspaces with the same name

What this error means

In npm workspaces, the `name` field in each package.json serves as the unique identifier for that workspace. When npm detects two or more packages with the same `name` value across your monorepo structure, it cannot determine which workspace to reference and throws the EDUPLICATEWORKSPACE error. Workspaces are identified by their package.json name field, not by their folder names, so duplicates cause ambiguity in the dependency resolution and workspace management system. This is a strict requirement in npm (and Yarn) to ensure workspace integrity.

Typical symptoms

  • npm install fails with the error message 'must not have multiple workspaces with the same name'
  • The error provides no details about which packages have duplicate names
  • Monorepo operations like npm run scripts across workspaces fail to execute
  • Workspace dependency resolution fails when trying to reference dependencies across packages
  • CI/CD pipelines fail during the install phase with unclear error messaging

Common causes

  1. Two or more packages in your workspaces have identical `name` values in their package.json files
  2. Accidentally copy-pasting a package folder without updating the name field in package.json
  3. Merging code from different branches that each created similarly-named packages
  4. Auto-generated or templated packages that retained placeholder names across multiple workspaces
  5. Scoped packages with identical base names in different workspaces

How to fix "npm ERR! code EDUPLICATEWORKSPACE npm ERR! must not have multiple workspaces with the same name"

1Find all duplicate workspace package names

First, identify which workspaces have duplicate names. You can use grep to extract all workspace names:

bash
find . -path ./node_modules -prune -o -name 'package.json' -type f -exec grep -H '"name"' {} \;

On Windows PowerShell:

powershell
Get-ChildItem -Path . -Filter 'package.json' -Recurse | Select-String '"name"'

This will show all package.json files with their name fields. Look for any names that appear more than once.

2Examine your root package.json workspaces configuration

Review the workspaces field in your root package.json to understand which directories are included:

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

Note all glob patterns, as they may be catching duplicate packages.

3Rename duplicate workspace packages

Update the name field in each duplicate package.json to be unique. Use a consistent naming convention, preferably with scoping:

json
{
  "name": "@mycompany/auth",
  "version": "1.0.0"
}

For example, if you have packages/api and services/api both with name "api", rename them to:
- packages/api/package.json: "name": "@mycompany/api-packages"
- services/api/package.json: "name": "@mycompany/api-services"

4Clear npm cache and reinstall dependencies

After updating all duplicate package names, clean your npm cache and reinstall:

bash
rm -rf node_modules package-lock.json
npm cache clean --force
npm install

This ensures npm re-validates your workspace configuration with the corrected names.

5Verify workspace references in dependent packages

After renaming, update any cross-workspace dependencies in your package.json files to reference the new names:

json
{
  "name": "@mycompany/app",
  "dependencies": {
    "@mycompany/api-services": "workspace:*"
  }
}

The workspace:* protocol ensures the dependency points to the local workspace version rather than npm registry.

Advanced notes

Unlike pnpm, which allows multiple projects with the same name in a monorepo, npm strictly enforces unique workspace names due to how it resolves and hoists dependencies. If you're using scoped packages (e.g., @mycompany/package-name), ensure the full scoped name is unique, not just the base package name. The npm error message intentionally doesn't specify which packages are duplicated; use the grep command to identify duplicates before npm install runs.

Frequently asked questions

What does "npm ERR! code EDUPLICATEWORKSPACE npm ERR! must not have multiple work" mean?
json serves as the unique identifier for that workspace. When npm detects two or more packages with the same name value across your monorepo structure, it cannot determine which workspace to reference and throws the EDUPLICATEWORKSPACE error. json name field, not by their folder names, so duplicates cause ambiguity in the dependency resolution and workspace management system.
How do I fix "npm ERR! code EDUPLICATEWORKSPACE npm ERR! must not have multiple work"?
This error occurs when your npm monorepo has multiple workspace packages with identical names in their package.json files. Each workspace must have a unique name value to avoid conflicts.
What causes "npm ERR! code EDUPLICATEWORKSPACE npm ERR! must not have multiple work"?
Two or more packages in your workspaces have identical name values in their package.json files Accidentally copy-pasting a package folder without updating the name field in package.json Merging code from different branches that each created similarly-named packages
Is the "npm ERR! code EDUPLICATEWORKSPACE npm ERR! must not have multiple work" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading