Fixing “No workspaces found” in npm
When you see npm error No workspaces found:, the value you passed to --workspace (or -w) does not match any workspace's name or path. For example, passing the folder name web causes this error. Pass the name from package.json (such as @example/web) or the path from the root (packages/web) instead, and the error goes away.
This is the fix for when you try to run npm run build in just one workspace of a monorepo, or add a package with npm install, and get stopped by this error. I reproduced the error in a test environment, checked the message it printed, and confirmed that changing the value fixed it.
The test environment was Ubuntu 24.04. I mainly tested with Node.js 22.23.5 (npm 10.9.9). For comparison, I also tested with npm 11.19.1, which comes with Node.js 24.22.3, covering the folder-name case, the case where all given values miss, and the case where I used the name. I mainly used npm run, and npm install in some cases. I did not test Windows or macOS, yarn or pnpm, npm 9 or earlier, or a real CI service.
- 1. The monorepo used for testing
- 2. The message you get when you pass a folder name
- 3. Passing the name or path clears the error
- 4. Typos and case differences also cause the error
- 5. With several values, one match is enough to avoid the error
- 6. Paths are resolved from the current folder when you run from a subfolder
- 7. When the folder is not in the workspaces list
- 8. The same applies to npm install and npm 11
The monorepo used for testing
I put "workspaces": ["packages/*"] in the root package.json and created two workspaces, packages/web and packages/api. The relationship between folder names and name values was as follows.
| Folder | name in package.json |
|---|---|
| packages/web | @example/web |
| packages/api | api |
Both have a build script that just prints build web or build api. I ran npm install once at the root before testing.
The message you get when you pass a folder name
From the root folder, I ran npm run build with the folder name web. It printed the following and exited with code 1. In the output in this article, I replaced the log file path with ~/.npm/_logs. In the later outputs, I omitted the last log line (npm error A complete log of this run can be found in: …).
$ npm run build --workspace=web
npm error No workspaces found:
npm error --workspace=web
npm error A complete log of this run can be found in: ~/.npm/_logs/2026-11-24T12_02_26_754Z-debug-0.log
The second line prints the value that did not match, exactly as given. web is a folder name, and the name is @example/web, so it does not match as a name. The path from the root is packages/web, so it does not match as a path either.
The npm config page's description of workspace says that workspace accepts three forms: the workspace name, the path to the workspace folder, and the path to the parent folder that contains the workspace. In the npm 10.9.9 source, the value is checked against these three forms in order, and the No workspaces found error is raised only when none of them match.
Passing the name or path clears the error
In the same location, each of the following four forms ran without error, printed build web, and exited with code 0.
$ npm run build --workspace=@example/web
> @example/web@1.0.0 build
> echo build web
build web
$ npm run build --workspace=packages/web
$ npm run build --workspace=./packages/web
$ npm run build -w @example/web
The second and later commands produced the same output as the first (omitted here). -w is the short form of --workspace, as listed in the config page's list of shorthands.
If you do not know the correct name, run npm pkg get name --workspaces at the root. It prints the name of each workspace.
$ npm pkg get name --workspaces
{
"api": "api",
"@example/web": "@example/web",
"lint": "lint"
}
(lint is a workspace I added later in this article.)
Typos and case differences also cause the error
When I passed a typo, apl, or the uppercase API, to the workspace whose name is api, both gave the same kind of error.
$ npm run build --workspace=apl
npm error No workspaces found:
npm error --workspace=apl
$ npm run build --workspace=API
npm error No workspaces found:
npm error --workspace=API
Changing it to --workspace=api printed build api and exited with code 0. Write the name exactly as it appears in name, including case.
With several values, one match is enough to avoid the error
You can pass --workspace more than once. When all the values miss, they are printed together on one line.
$ npm run build --workspace=apl --workspace=web
npm error No workspaces found:
npm error --workspace=apl --workspace=web
When one value matches and another does not, as in --workspace=api --workspace=web, there was neither an error nor a warning. Only build api ran, and the exit code was 0. A CI job that decides success by the exit code will not stop, so it is easy to miss that the web build never ran.
In the npm 10.9.9 source, an error is raised only when none of the workspaces match.
If you want to run a command on several workspaces at once, you can also pass the parent folder. --workspace=packages ran build in both api and web inside packages.
Paths are resolved from the current folder when you run from a subfolder
When you give a path, it is treated as relative to the folder where you run the command, not to the root. When I moved into the packages folder and ran the command, packages/web, which worked at the root, gave the error. Conversely, the folder name alone, web, worked.
$ npm run build --workspace=packages/web
npm error No workspaces found:
npm error --workspace=packages/web
$ npm run build --workspace=web
> @example/web@1.0.0 build
> echo build web
build web
Inside packages/api, packages/web also gave the error, while ../web worked. Using the name, as in --workspace=@example/web, worked at the root and also inside packages and packages/api. If you write the value in scripts or CI configuration, using the name keeps it from depending on where the command runs.
When the folder is not in the workspaces list
I created a folder tools/lint with a package.json whose name is lint. The root workspaces is still packages/*, so this folder is not a workspace. Both --workspace=lint and --workspace=tools/lint gave the same error.
$ npm run build --workspace=tools/lint
npm error No workspaces found:
npm error --workspace=tools/lint
In this case, add the folder to workspaces in the root package.json. I ran npm pkg set 'workspaces[1]=tools/*' to make it "workspaces": ["packages/*", "tools/*"], then ran npm install. After that, npm run build --workspace=lint printed build lint and exited with code 0.
In a project whose root package.json has no workspaces at all, --workspace=api gave the same kind of error. When I used --workspaces (plural), which runs against all workspaces, the message was a single line with no list of values, and it ended with "!" instead of ":".
$ npm run test --workspaces
npm error No workspaces found!
The same applies to npm install and npm 11
npm install ms --workspace=web, which uses a folder name, also gave the same No workspaces found: error. Changing it to npm install ms@2.1.3 --workspace=@example/web installed ms and added "ms": "^2.1.3" to dependencies in packages/web/package.json.
With npm 11.19.1, the messages for --workspace=web and for all-missing values such as --workspace=apl --workspace=web2 were the same as with npm 10.9.9. Changing it to --workspace=@example/web exited with code 0.





