Skip to content

npm ERR! Unsupported URL Type "workspace:": workspace:*

When using npm to install packages, you might encounter the error npm ERR! Unsupported URL Type "workspace:": workspace:*. This typically occurs when your project contains workspace dependencies that npm doesn't support, but other package managers like Yarn or pnpm do.

Problem Overview

The error happens when your package.json file contains dependencies with the workspace: protocol, which is used by package managers that support monorepo workspace management. Standard npm (as of 2021) doesn't understand this protocol and throws an unsupported URL type error.

Common scenarios where this occurs:

  • Cloning monorepo projects that use Yarn or pnpm workspaces
  • Projects with internal package references using workspace:* syntax
  • Migrating between package managers without updating dependency references

Solutions

1. Use the Correct Package Manager

Most projects with workspace dependencies are designed for specific package managers:

bash
yarn install
bash
pnpm install

INFO

If you don't have the required package manager installed, you'll need to install it first:

bash
# Install yarn globally
npm install -g yarn

# Install pnpm globally  
npm install -g pnpm

2. Modify package.json Dependencies

If you must use npm, manually update the package.json to replace workspace references:

json
{
  "dependencies": {
    "@repo/typescript-config": "workspace:*",
    "internal-package": "workspace:^"
  }
}
json
{
  "dependencies": {
    "@repo/typescript-config": "*",
    "internal-package": "^1.0.0" // Use actual version
  }
}

WARNING

This approach may break functionality if the workspace packages have specific version requirements or unpublished changes.

3. Check Node.js Version Compatibility

Some users have reported success by downgrading Node.js, though this isn't recommended as a long-term solution:

bash
# Using nvm to switch Node versions
nvm install 16.11.0
nvm use 16.11.0

4. Verify Terminal Environment

In rare cases, the terminal environment might affect package installation. Try using a different terminal:

  • Switch between Command Prompt, PowerShell, or WSL
  • Try the built-in terminal in your IDE vs. system terminal
  • Ensure you have appropriate permissions (run as administrator if needed)

Understanding Workspace Dependencies

Workspace dependencies (workspace:*) are a feature of modern package managers that allow you to:

  • Reference local packages within a monorepo
  • Ensure consistent versioning across related packages
  • Enable seamless development across multiple interconnected packages

The following package managers support workspace protocol:

Package ManagerWorkspace SupportInstallation Command
Yarn✅ Yesyarn install
pnpm✅ Yespnpm install
npm❌ No (as of 2021)npm install

Best Practices

  1. Check project documentation - Most projects specify their preferred package manager
  2. Use consistent package management - Don't switch between npm, Yarn, and pnpm arbitrarily
  3. Update package.json carefully - Only modify workspace references if you understand the dependencies
  4. Consider using corepack - Modern Node.js versions include corepack for managing package managers
bash
# Enable corepack (Node.js 16.9+)
corepack enable

# Then let corepack handle the package manager
corepack yarn install

When to Use Which Solution

  • Team projects: Use the package manager specified in the project documentation
  • Personal projects: Choose based on your preference (Yarn/pnpm for workspaces)
  • Quick fixes: Temporary version changes work but aren't sustainable
  • Production environments: Always use the intended package manager for consistency

By understanding the workspace protocol and using the appropriate package manager, you can avoid the "Unsupported URL Type" error and successfully install dependencies for modern JavaScript projects.