ui
ui copied to clipboard
[bug]: monorepo CLI fails to create project `BUN`
Describe the bug
When attempting to create a new Next.js monorepo project using the shadcn CLI (canary version), the process fails due to missing workspace dependencies.
Affected component/components
CLI
How to reproduce
Steps to Reproduce
- Run the following command:
bunx --bun shadcn@canary init - Choose "Next.js (Monorepo)" when prompted to start a new project
- Enter a project name (e.g., "test-monorp-shadcn")
Expected Behavior
The CLI should successfully create a new Next.js monorepo project with all necessary dependencies and configurations.
Actual Behavior
The CLI fails to create the project, reporting missing workspace dependencies:
✖ 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.
# Logs section...
Codesandbox/StackBlitz link
No response
Logs
PS C:\Users\Jozef\Desktop> bunx --bun shadcn@canary init
√ The path C:\Users\Jozef\Desktop does not contain a package.json file.
Would you like to start a new project? » Next.js (Monorepo)
√ What is your project named? ... test-monorp-shadcn
✖ 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
error: Workspace dependency "@workspace/eslint-config" not found
Searched in "..\..\..\..\..\C:\Users\Jozef\Desktop\test-monorp-shadcn\*"
Workspace documentation: https://bun.sh/docs/install/workspaces
error: Workspace dependency "@workspace/typescript-config" not found
Searched in "..\..\..\..\..\C:\Users\Jozef\Desktop\test-monorp-shadcn\*"
Workspace documentation: https://bun.sh/docs/install/workspaces
error: @workspace/eslint-config@* failed to resolve
error: @workspace/typescript-config@* failed to resolve
bun install v1.1.42 (50eec002)
System Info
- Operating System: Windows 11 version 23H2 (SO 22631.4602)
- Node.js version: v22.11.0
- Bun version: 1.1.42
- shadcn CLI version: canary
Before submitting
- [X] I've made research efforts and searched the documentation
- [X] I've searched for existing issues
When using NPM, a similar error occurs, as it uses a package.json file following the PNPM standard, where imports are defined with "workspace:*". However, for NPM, it should be "*".
> npx shadcn@canary init
✔ The path /home/william/github does not contain a package.json file.
Would you like to start a new project? › Next.js (Monorepo)
✔ What is your project named? … shadcn
✖ 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: /home/william/.npm/_logs/2024-12-22T15_42_12_265Z-debug-0.log
And when I used pnpm
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 /home/kenil/Desktop/Super Kenil/Test
spawn cd ENOENT
In order to get it to work correctly with bun I removed the pnpm related files (pnpm-lock.yaml and pnpm-workspaces.yaml) and changed my package.json workspaces and packageManager entries:
{
"name": "shadcn-ui-monorepo",
"version": "0.0.1",
"private": true,
"scripts": {
"build": "turbo build",
"dev": "turbo dev",
"lint": "turbo lint",
"format": "prettier --write \"**/*.{ts,tsx,md}\""
},
"devDependencies": {
"@workspace/eslint-config": "workspace:*",
"@workspace/typescript-config": "workspace:*",
"prettier": "^3.2.5",
"turbo": "^2.3.0",
"typescript": "5.5.4"
},
"packageManager": "[email protected]",
"engines": {
"node": ">=20"
},
"workspaces": [
"apps/*",
"packages/*"
]
}
Tip
to install the CLI with bun, do not use bunx --bun shadcn@latest init, better use bunx --bun shadcn init I'm not a shadcn dev, I don't know if it's the most recommended, but it works for me, you're welcome.
This is for monorepos which specify
bunx --bun shadcn@canary init
in the docs
@SelfhostedPro
bunx --bun shadcn init
✔ The path /Users/bhaskaranrathnachalam/Documents/monrepo does not contain a package.json file. Would you like to start a new Next.js project? … yes ✔ What is your project named? … my-app ⠴ Creating a new Next.js project. This may take a few minutes. Something went wrong creating a new Next.js project. Please try again.
what do i do here?
bunx --bun shadcn init✔ The path /Users/bhaskaranrathnachalam/Documents/monrepo does not contain a package.json file. Would you like to start a new Next.js project? … yes ✔ What is your project named? … my-app ⠴ Creating a new Next.js project. This may take a few minutes. Something went wrong creating a new Next.js project. Please try again.
what do i do here?
https://github.com/shadcn-ui/ui/issues/6145#issuecomment-2564415085
Does it create the folder and files? If it does, just removing pnpm-workspace.yaml and pnpn-lock.json and adding the workspaces section I noted above should take care of it.
Yeah, what @SelfhostedPro mentioned is indeed a working workaround for now. It looks like the cli just scaffolds the project for pnpm, so we need to just make a few changes to switch to bun.
same issue facing: pnpm dlx [email protected] init ✔ The path /home/anil/Documents/VisualStudioCode/CodeWithAntonioProjects does not contain a package.json file. Would you like to start a new project? › Next.js (Monorepo) ✔ What is your project named? … echoes-ai ✖ 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 /home/anil/Documents/VisualStudioCode/CodeWithAntonioProjects spawn cd ENOENT
any update on this ?
failed to compile :
any update on this ?
failed to compile :
![]()
quick fix is to also install @tailwindcss/postcss in the next app
failed to compile :