日本語

How to Fix the npm EUNSUPPORTEDPROTOCOL Error

​​npm​Node.js,pnpm,Troubleshooting

If npm install shows npm error code EUNSUPPORTEDPROTOCOL and Unsupported URL Type "workspace:", a dependency in one of your package.json files uses the workspace:* syntax, which pnpm and other tools use. npm cannot read this syntax. If the project is meant for pnpm, install with pnpm. If you want to keep using npm, rewrite workspace:* as a version specifier such as *, and add workspaces to the root package.json. The error then goes away.

This error appears when you clone a pnpm monorepo (a repository that holds multiple packages) and run npm install, or when you try to switch from pnpm to npm. I reproduced the error in a test environment, recorded the full message, and confirmed that the fixes below make it go away.

Note

The test environment was Ubuntu 24.04. I mainly tested with Node.js 22.23.5 (npm 10.9.9) and pnpm 10.28.0. For comparison, I also ran the same steps with npm 9.9.4 and with npm 11.19.1, which comes bundled with Node.js 24.22.3. The example packages @demo/utils and @demo/app were made for this test and are not published to npm. I did not test installs on Windows or macOS, or with Yarn or Bun.

The full error message

The test used a monorepo with two packages under packages/: @demo/utils, a shared library, and @demo/app, which uses it. The root package.json has npm's workspace setting (workspaces).

json
{
  "name": "mono",
  "private": true,
  "workspaces": ["packages/*"]
}

In packages/app/package.json, @demo/utils is referenced with the pnpm syntax.

json
{
  "name": "@demo/app",
  "version": "1.0.0",
  "dependencies": {
    "@demo/utils": "workspace:*"
  }
}

When I ran npm install in the root with npm 10.9.9, it stopped with the following output (exit code 1). In the output in this article, I replaced the log file path with ~/.npm/_logs.

text
$ npm install
npm error code EUNSUPPORTEDPROTOCOL
npm error Unsupported URL Type "workspace:": workspace:*
npm error A complete log of this run can be found in: ~/.npm/_logs/2026-11-21T16_28_24_941Z-debug-0.log

The Unsupported URL Type line means that npm does not support this type of specifier, workspace:. The last part, workspace:*, is the value exactly as written in package.json. When the value was workspace:^, the message was Unsupported URL Type "workspace:": workspace:^. After the error, neither node_modules nor package-lock.json was created. Running npm install in the packages/app folder gave the same error.

With npm 11.19.1, the output was the same three lines, except for the date in the log file name. With npm 9.9.4, each line starts with npm ERR!, and there is an empty line before the last line.

text
$ npx -y npm@9.9.4 install
npm ERR! code EUNSUPPORTEDPROTOCOL
npm ERR! Unsupported URL Type "workspace:": workspace:*

npm ERR! A complete log of this run can be found in: ~/.npm/_logs/2026-11-21T16_28_26_754Z-debug-0.log

The message on screen does not say which package.json the value came from.

workspace: is a pnpm and Yarn syntax

workspace: is a syntax for referencing other packages inside a monorepo. The pnpm 10 official docs (source files on GitHub), in the workspace section, describe it as "Workspace protocol (workspace:)". The Yarn documentation has a syntax with the same name.

The dependency specifiers npm accepts are listed on the official package spec page: a package name with a version (or a tag or range), aliases using npm:, folders, tarball files (local or URL), and git URLs. workspace: is not among them.

Looking at the code that parses specifiers in npm 10.9.9 (npm-package-arg), a value that starts with letters: is read as a URL. If the scheme is not one npm knows, such as git: or https:, it raises EUNSUPPORTEDPROTOCOL. workspace:* matches this pattern.

For a pnpm project, install with pnpm

If the root has pnpm-workspace.yaml or pnpm-lock.yaml, the repository was designed to be installed with pnpm. Stop using npm and run pnpm install. You don't need to change package.json. As the pnpm docs above explain, pnpm defines its workspace in pnpm-workspace.yaml at the root.

In the test, I used the same two packages (@demo/app still depends on workspace:*) and created this pnpm-workspace.yaml in the root:

yaml
packages:
  - packages/*

pnpm install finished without errors (exit code 0) and printed Already up to date. This example has no external dependencies. The Scope value of 3 is the total of the root and the two packages.

text
$ pnpm install
Scope: all 3 workspace projects
Already up to date

Done in 288ms using pnpm v10.28.0

packages/app/node_modules/@demo/utils became a symbolic link to packages/utils. Running packages/app/index.js, which calls require("@demo/utils"), printed the result of a utils function (hello, npm).

To use npm, rewrite workspace:*

If you don't use pnpm and want to keep the npm workspace, edit package.json. First, find the package.json files that contain workspace:. Exclude node_modules.

text
$ grep -rn --include=package.json --exclude-dir=node_modules '"workspace:' .
./packages/app/package.json:5:    "@demo/utils": "workspace:*"

Replace each value you find with a version specifier that npm can read. You can edit the file in an editor. In the test, I used npm pkg set to change the @demo/app dependency to * (any version).

text
$ npm pkg set 'dependencies.@demo/utils=*' -w packages/app
$ npm install

added 2 packages, and audited 5 packages in 288ms

found 0 vulnerabilities

It finished without errors (exit code 0). As the npm workspaces docs explain, packages in folders listed in workspaces are placed in the root node_modules as symbolic links.

text
$ ls -l node_modules/@demo
total 0
lrwxrwxrwx 1 root root 18 Nov 21 16:28 app -> ../../packages/app
lrwxrwxrwx 1 root root 20 Nov 21 16:28 utils -> ../../packages/utils

npm ls --all also showed that @demo/utils, used by app, links to ./packages/utils. I replaced the project path with /path/to/mono.

text
$ npm ls --all
mono@ /path/to/mono
+-- @demo/app@1.0.0 -> ./packages/app
| `-- @demo/utils@1.0.0 deduped -> ./packages/utils
`-- @demo/utils@1.0.0 -> ./packages/utils

package-lock.json recorded node_modules/@demo/utils with "resolved": "packages/utils" and "link": true. This shows that the package comes from a folder in the repository, not from the registry.

Using a range that includes utils' current version (^1.0.0) instead of * also installed correctly, and npm ls showed the same output.

Without workspaces in the root, you get E404 instead

Rewriting alone is not always enough. In a pnpm repository, package locations are defined in pnpm-workspace.yaml, so the root package.json may not have workspaces.

In the test, I removed workspaces from the root package.json, changed the @demo/utils specifier to ^1.0.0, and ran npm install in packages/app. It failed with E404, not EUNSUPPORTEDPROTOCOL. npm looked for @demo/utils in the registry (registry.npmjs.org) and did not find it.

text
$ cd packages/app
$ npm install
npm error code E404
npm error 404 Not Found - GET https://registry.npmjs.org/@demo%2futils - Not found
npm error 404
npm error 404  '@demo/utils@^1.0.0' is not in this registry.
npm error 404
npm error 404 Note that you can also install from a
npm error 404 tarball, folder, http url, or git url.
npm error A complete log of this run can be found in: ~/.npm/_logs/2026-11-21T16_28_28_393Z-debug-0.log

Go back to the root and add the folders that hold your packages to workspaces in the root package.json. If you have a pnpm-workspace.yaml, use the same entries as its packages list. Then run npm install in the root. It finished without errors.

text
$ cd ../..
$ npm pkg set 'workspaces[]=packages/*'
$ npm install

added 2 packages, and audited 5 packages in 293ms

found 0 vulnerabilities
Point

To install with npm, you need to do both: rewrite each workspace:* value, and list the package folders in workspaces in the root package.json.

catalog: gives the same error

pnpm also has a feature called catalogs. It lets you define dependency versions together in pnpm-workspace.yaml and write only catalog: in package.json. Running npm install on a package.json with "lodash": "catalog:" gave the same error code.

text
$ npm install
npm error code EUNSUPPORTEDPROTOCOL
npm error Unsupported URL Type "catalog:": catalog:
npm error A complete log of this run can be found in: ~/.npm/_logs/2026-11-21T16_28_29_686Z-debug-0.log

The text in quotes after Unsupported URL Type ("workspace:" or "catalog:") tells you which syntax is the cause. If you use npm, rewrite catalog: as a normal version specifier too. In the test, I changed it to "lodash": "^4.17.21". npm install then finished without errors and installed lodash 4.18.1.

​Posted by 86