ui: [bug]: npm error Unsupported URL Type "workspace:": workspace:* using npx shadcn@canary init
Describe the bug
When creating a new project and running npx shadcn@canary init, selecting the next.js(monorepo) version results in an EUNSUPPORTEDPROTOCOL error.
In my opinion, The reason for this is likely that Shadcn defaults to npm when it cannot detect a package manager, then attempts to run the npm install command. However, the monorepo template files are based on pnpm, which causes compatibility issues and results in the error
Affected component/components
CLI init(monorepo)
How to reproduce
- make empty project
- execute
npx shadcn@canary init - Would you like to start a new project? › Next.js (Monorepo)
Codesandbox/StackBlitz link
No response
Logs
shadcn-mono-test git:(main) npx shadcn@canary init
✔ The path /Users/jh/shadcn-mono-test does not contain a package.json file.
Would you like to start a new project? › Next.js (Monorepo)
✔ What is your project named? … my-app
✖ Something went wrong creating a new Next.js monorepo.
Something went wrong. Please check the error below for more details.
If the problem persists, please open an issue on GitHub.
Command failed with exit code 1: 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: /Users/jh/.npm/_logs/2025-01-22T06_59_21_296Z-debug-0.log
System Info
mac
Before submitting
- I’ve made research efforts and searched the documentation
- I’ve searched for existing issues
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 16
mac, npm. failing as above when choosing monorepo during init
This is an issue with the package manager in your monorepo. The shadcn init script is returning a pnpm repository, not npm. To turn the pnpm repository into a npm repository:
dependenciesanddevDependenciesvalues in package.json files from"workspace:*"and"workspace:^"to"*"apps/*andpackages/*as workspaces.See here: https://turbo.build/repo/docs/crafting-your-repository/managing-dependencies
Why was this issue closed? As of 2.5.0,
shadcn initstill doesn’t support package managers other than pnpm when using the monorepo template. I had to spend an hour debugging this today.The only way i got this to work is to install shadcn after installing next with “npx create-next-app”. Essentially you need an existing nextjs project to install it in through npm.