ui icon indicating copy to clipboard operation
ui copied to clipboard

[bug]: EUNSUPPORTEDPROTOCOL while trying to create monorepo

Open iChintanSoni opened this issue 1 year ago • 8 comments

Describe the bug

While creating a new monorepo project, it throws below error:

chintansoni@192 projects % npx shadcn@canary init
✔ The path /Users/chintansoni/projects does not contain a package.json file.
  Would you like to start a new project? › Next.js (Monorepo)
✔ What is your project named? … shadcn-monorepo
✖ 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/chintansoni/.npm/_logs/2024-12-28T06_33_50_510Z-debug-0.log

Affected component/components

Project creation

How to reproduce

  1. Go to the terminal
  2. Execute: npx shadcn@canary init
  3. In the first prompt Would you like to start a new project?, select Next.js (Monorepo)
  4. In the next prompt What is your project named?, enter the project name shadcn-monorepo

Codesandbox/StackBlitz link

No response

Logs

0 verbose cli /Users/chintansoni/.nvm/versions/node/v22.8.0/bin/node /Users/chintansoni/.nvm/versions/node/v22.8.0/bin/npm
1 info using [email protected]
2 info using [email protected]
3 silly config load:file:/Users/chintansoni/.nvm/versions/node/v22.8.0/lib/node_modules/npm/npmrc
4 silly config load:file:/Users/chintansoni/projects/shadcn-monorepo/.npmrc
5 silly config load:file:/Users/chintansoni/.npmrc
6 silly config load:file:/Users/chintansoni/.nvm/versions/node/v22.8.0/etc/npmrc
7 verbose title npm install
8 verbose argv "install"
9 verbose logfile logs-max:10 dir:/Users/chintansoni/.npm/_logs/2024-12-28T06_33_50_510Z-
10 verbose logfile /Users/chintansoni/.npm/_logs/2024-12-28T06_33_50_510Z-debug-0.log
11 silly logfile start cleaning logs, removing 1 files
12 silly packumentCache heap:2197815296 maxSize:549453824 maxEntrySize:274726912
13 silly logfile done cleaning log files
14 silly idealTree buildDeps
15 verbose stack Error: Unsupported URL Type "workspace:": workspace:*
15 verbose stack     at unsupportedURLType (/Users/chintansoni/.nvm/versions/node/v22.8.0/lib/node_modules/npm/node_modules/npm-package-arg/lib/npa.js:310:15)
15 verbose stack     at fromURL (/Users/chintansoni/.nvm/versions/node/v22.8.0/lib/node_modules/npm/node_modules/npm-package-arg/lib/npa.js:367:13)
15 verbose stack     at Function.resolve (/Users/chintansoni/.nvm/versions/node/v22.8.0/lib/node_modules/npm/node_modules/npm-package-arg/lib/npa.js:83:12)
15 verbose stack     at #nodeFromEdge (/Users/chintansoni/.nvm/versions/node/v22.8.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1039:22)
15 verbose stack     at #buildDepStep (/Users/chintansoni/.nvm/versions/node/v22.8.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:904:35)
15 verbose stack     at #buildDeps (/Users/chintansoni/.nvm/versions/node/v22.8.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:757:30)
15 verbose stack     at Arborist.buildIdealTree (/Users/chintansoni/.nvm/versions/node/v22.8.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:181:28)
15 verbose stack     at async Promise.all (index 1)
15 verbose stack     at async Arborist.reify (/Users/chintansoni/.nvm/versions/node/v22.8.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:131:5)
15 verbose stack     at async Install.exec (/Users/chintansoni/.nvm/versions/node/v22.8.0/lib/node_modules/npm/lib/commands/install.js:150:5)
16 error code EUNSUPPORTEDPROTOCOL
17 error Unsupported URL Type "workspace:": workspace:*
18 silly unfinished npm timer reify 1735367630748
19 silly unfinished npm timer reify:loadTrees 1735367630748
20 silly unfinished npm timer idealTree:buildDeps 1735367630753
21 silly unfinished npm timer idealTree:#root 1735367630753
22 verbose cwd /Users/chintansoni/projects/shadcn-monorepo
23 verbose os Darwin 24.2.0
24 verbose node v22.8.0
25 verbose npm  v10.9.0
26 verbose exit 1
27 verbose code 1
28 error A complete log of this run can be found in: /Users/chintansoni/.npm/_logs/2024-12-28T06_33_50_510Z-debug-0.log

System Info

Macbook Air
Chip: Apple M2
Memory: 8 GB
OS: Sequoia

Before submitting

  • [X] I've made research efforts and searched the documentation
  • [X] I've searched for existing issues

iChintanSoni avatar Dec 28 '24 06:12 iChintanSoni

Same problem here on WSL on Windows 11 and MacOS too.

pirmax avatar Dec 28 '24 16:12 pirmax

As a workaround, you can check my own Turborepo with shadcn as a package

https://github.com/PedroMarianoAlmeida/offical-turbo-v1/tree/main/packages/react/shadcn

I start with this example (https://github.com/vercel/turborepo/tree/main/examples/with-tailwind) and then start working on that

PedroMarianoAlmeida avatar Dec 29 '24 05:12 PedroMarianoAlmeida

Using pnpm solved this issue for me.

morganbarber avatar Dec 31 '24 04:12 morganbarber

despite the documentation showing the scripts for init for npm, pnpm, bun, etc... clearly the only one they tested was pnpm. I think we have to just dump contents of the example folder into your new project, delete the pnpm stuff, add the workspaces to the package.json, etc.

z1haze avatar Jan 09 '25 00:01 z1haze

Same

evokerking2 avatar Jan 14 '25 15:01 evokerking2

I faced this issue while i was on [email protected] (if I'm not mistaken, does not support workspace). Using [email protected] solves the issue

qwerqy avatar Jan 16 '25 12:01 qwerqy

It seems that Shadcn defaults to npm when it cannot detect a package manager(getPackageManager function), and then runs the install command. However, the monorepo template are based on pnpm, which causes errors.

whdgur5717 avatar Jan 22 '25 07:01 whdgur5717

Use pnpm dlx shadcn@latest add

meetwudi avatar Mar 12 '25 05:03 meetwudi

@shadcn I'm following instructions from https://ui.shadcn.com/docs/monorepo and so far I've tried

pnpm dlx shadcn@latest init successfully creates monorepo ✅

? Would you like to start a new project?
    Next.js
❯   Next.js (Monorepo)
see full logs
pnpm dlx shadcn@canary init
 WARN  1 deprecated subdependencies found: [email protected]
Packages: +288
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 288, reused 287, downloaded 1, added 288, done
✔ The path /Users/sultanmyrza/Development/monorepo-projects/try-shadcn-monorepo does not contain a package.json file.
  Would you like to start a new project? › Next.js (Monorepo)
✔ What is your project named? … shadcn-turborepo-with-pnpm
✔ Creating a new Next.js monorepo.
Success! Project initialization completed.
You may now add components.


npx shadcn@latest init throws an Error ❌

? Would you like to start a new project?
    Next.js
❯   Next.js (Monorepo)
see full logs
npx shadcn@latest init
✔ The path /Users/sultanmyrza/Development/monorepo-projects/try-shadcn-monorepo does not contain a package.json file.
  Would you like to start a new project? › Next.js (Monorepo)
✔ What is your project named? … shadcn-turborepo-with-npm
✖ 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/sultanmyrza/.npm/_logs/2025-05-02T03_44_31_849Z-debug-0.log

bunx --bun shadcn@latest init thows an Error ❌

? Would you like to start a new project?
    Next.js
❯   Next.js (Monorepo)
see full logs
bunx --bun shadcn@canary init
✔ The path /Users/sultanmyrza/Development/monorepo-projects/try-shadcn-monorepo does not contain a package.json file.
  Would you like to start a new project? › Next.js (Monorepo)
✔ What is your project named? … shadcn-turborepo-with-bun
✖ 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: bun install
Resolving dependencies
Resolved, downloaded and extracted [4]
error: Workspace dependency "@workspace/eslint-config" not found

Searched in "./*"

Workspace documentation: https://bun.sh/docs/install/workspaces


error: Workspace dependency "@workspace/typescript-config" not found

Searched in "./*"

Workspace documentation: https://bun.sh/docs/install/workspaces

error: @workspace/eslint-config@workspace:* failed to resolve
error: @workspace/typescript-config@workspace:* failed to resolve
bun install v1.2.7 (5c0fa6dc)

Here is my environment

$ npx envinfo --system --npmPackages '@lynx-js/*' --binaries

  System:
    OS: macOS 15.4
    CPU: (8) arm64 Apple M1 Pro
    Memory: 202.27 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
    Yarn: 4.9.1 - ~/.nvm/versions/node/v22.14.0/bin/yarn
    npm: 10.9.2 - ~/.nvm/versions/node/v22.14.0/bin/npm
    pnpm: 10.7.0 - ~/.nvm/versions/node/v22.14.0/bin/pnpm
    bun: 1.2.7 - ~/.bun/bin/bun

sultanmyrza avatar May 02 '25 03:05 sultanmyrza

Anyone solved this? This does NOT work

npx shadcn@latest init throws an Error ❌

? Would you like to start a new project?
    Next.js
❯   Next.js (Monorepo)
see full logs
npx shadcn@latest init
✔ The path /Users/sultanmyrza/Development/norepo-projects/try-shadcn-monorepo does not contain package.json file.
  Would you like to start a new project? › Next.js onorepo)
✔ What is your project named? … adcn-turborepo-with-npm
✖ Something went wrong creating a new Next.js norepo.
Something went wrong. Please check the error below r more details.
If the problem persists, please open an issue on tHub.

Command failed with exit code 1: npm install
npm error code EUNSUPPORTEDPROTOCOL
npm error Unsupported URL Type "workspace:": rkspace:*
npm error A complete log of this run can be found : /Users/sultanmyrza/.npm/_logs/25-05-02T03_44_31_849Z-debug-0.log

madebydor avatar May 08 '25 19:05 madebydor

Same :(

lonadels avatar Jul 24 '25 14:07 lonadels

the issue persists for me on wsl with pnpm and npm

valerius21 avatar Aug 12 '25 15:08 valerius21

pnpm dlx shadcn@canary init does NOT work for me

✖ 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 ENOENT: cd /workspaces/shadcn-monorepo-example
spawn cd ENOENT

johncmunson avatar Oct 01 '25 21:10 johncmunson