shadcn-ui / ui

Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.
https://ui.shadcn.com
MIT License
74.47k stars 4.61k forks source link

CLI doesn't work with `bun` #703

Closed MarkLyck closed 1 year ago

MarkLyck commented 1 year ago

I tried using the CLI to init shadcn ui in my project, but it doesn't work with bun.

I get the following error on install:

bunx shadcn-ui@latest init
✔ Which style would you like to use? › New York
✔ Which color would you like to use as base color? › Zinc
✔ Where is your global CSS file? … ./src/styles/global.css
✔ Do you want to use CSS variables for colors? … no / yes
✔ Where is your tailwind.config.js located? … tailwind.config.js
✔ Configure the import alias for components: … @/components/ui
✔ Configure the import alias for utils: … @/lib/utils
✔ Are you using React Server Components? … no / yes
✔ Write configuration to components.json. Proceed? … yes

✔ Writing components.json...
✔ Initializing project...
⠹ Installing dependencies...Command failed with exit code 1: npm install tailwindcss-animate class-variance-authority clsx tailwind-merge @radix-ui/react-icons
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @babel/helper-compilation-targets@7.22.5
npm WARN Found: @babel/core@7.21.4
npm WARN node_modules/@babel/helper-compilation-targets/node_modules/@babel/core
npm WARN   peer @babel/core@"^7.0.0" from @babel/helper-compilation-targets@7.21.4
npm WARN   node_modules/@babel/helper-compilation-targets/node_modules/@babel/core/node_modules/@babel/helper-compilation-targets
npm WARN     @babel/helper-compilation-targets@"^7.21.4" from @babel/core@7.21.4
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer @babel/core@"^7.0.0" from @babel/helper-compilation-targets@7.22.5
npm WARN node_modules/@babel/helper-compilation-targets
npm WARN   @babel/helper-compilation-targets@"^7.22.5" from @babel/core@7.22.5
npm WARN   node_modules/@babel/core
npm WARN   7 more (@babel/helper-define-polyfill-provider, ...)
npm ERR! Cannot read properties of null (reading 'matches')

npm ERR! A complete log of this run can be found in: /Users/marklyck/.npm/_logs/2023-06-25T09_24_42_515Z-debug-0.log
error: "shadcn-ui" exited with code 1 (SIGHUP)

npm ERR! Cannot read properties of null (reading 'matches')

I don't use npm in my project, so that may be why it's failing? I use bun.sh

bun version: 0.6.9 framework: react

dan5py commented 1 year ago

I tried testing it myself and it works just fine. Could you provide the log file? Also what version of bun and which framework are you using?

MarkLyck commented 1 year ago

@dan5py I was able to reproduce the error simply running npm install @radix-ui/react-slot so it's clearly not a shadcn CLI issue. But rather npm not working on my project. (I've never used npm in this project, so hadn't run into the error before).

and since the CLI doesn't support bun install, it defaults to npm and fails. I guess even if I resolve the npm error, it will still install it incorrectly and generate a package-lock.json, rather than use bun

Closing this issue, as it's clearly not a problem with the CLI, just missing support for bun.

0 verbose cli /usr/local/bin/node /usr/local/bin/npm
1 info using npm@9.7.2
2 info using node@v20.3.0
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 0ms
6 timing config:load:builtin Completed in 0ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:/Users/marklyck/web/ha-dash/.npmrc Completed in 0ms
10 timing config:load:project Completed in 1ms
11 timing config:load:file:/Users/marklyck/.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 1ms
15 timing config:load:setEnvs Completed in 0ms
16 timing config:load Completed in 4ms
17 timing npm:load:configload Completed in 4ms
18 timing config:load:flatten Completed in 1ms
19 timing npm:load:mkdirpcache Completed in 1ms
20 timing npm:load:mkdirplogs Completed in 0ms
21 verbose title npm install @radix-ui/react-slot
22 verbose argv "install" "@radix-ui/react-slot"
23 timing npm:load:setTitle Completed in 5ms
24 timing npm:load:display Completed in 1ms
25 verbose logfile logs-max:10 dir:/Users/marklyck/.npm/_logs/2023-06-25T12_04_44_022Z-
26 verbose logfile /Users/marklyck/.npm/_logs/2023-06-25T12_04_44_022Z-debug-0.log
27 timing npm:load:logFile Completed in 4ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 21ms
31 timing arborist:ctor Completed in 1ms
32 silly logfile start cleaning logs, removing 1 files
33 timing arborist:ctor Completed in 0ms
34 silly logfile done cleaning log files
35 timing idealTree:init Completed in 6387ms
36 timing idealTree:userRequests Completed in 1ms
37 silly idealTree buildDeps
38 silly fetch manifest @prisma/client@latest
39 http fetch GET 200 https://registry.npmjs.org/@prisma%2fclient 25ms (cache hit)
40 silly fetch manifest prisma@latest
41 http fetch GET 200 https://registry.npmjs.org/prisma 15ms (cache hit)
42 silly fetch manifest @radix-ui/react-slot@*
43 http fetch GET 200 https://registry.npmjs.org/@radix-ui%2freact-slot 4ms (cache hit)
44 silly fetch manifest @types/react@18.2.13
45 http fetch GET 200 https://registry.npmjs.org/@types%2freact 2ms (cache hit)
46 silly fetch manifest react@18.2.0
47 http fetch GET 200 https://registry.npmjs.org/react 3ms (cache hit)
48 silly placeDep ROOT @prisma/client@4.16.1 REPLACE for: ha-dash@0.1.0 want: latest
49 silly fetch manifest @prisma/engines-version@4.16.0-66.b20ead4d3ab9e78ac112966e242ded703f4a052c
50 silly placeDep ROOT @radix-ui/react-slot@1.0.2 REPLACE for: ha-dash@0.1.0 want: *
51 silly placeDep ROOT prisma@4.16.1 REPLACE for: ha-dash@0.1.0 want: latest
52 silly fetch manifest @prisma/engines@4.16.1
53 http fetch GET 200 https://registry.npmjs.org/@prisma%2fengines-version 14ms (cache hit)
54 http fetch GET 200 https://registry.npmjs.org/@prisma%2fengines 17ms (cache hit)
55 timing idealTree:#root Completed in 241ms
56 silly fetch manifest @babel/core@^7.0.0
57 http fetch GET 200 https://registry.npmjs.org/@babel%2fcore 4ms (cache hit)
58 silly placeDep ROOT @babel/core@7.22.5 KEEP for: @babel/helper-compilation-targets@7.22.5 want: ^7.0.0
59 warn ERESOLVE overriding peer dependency {
59 warn ERESOLVE   code: 'ERESOLVE',
59 warn ERESOLVE   edge: {
59 warn ERESOLVE     type: 'peer',
59 warn ERESOLVE     name: '@babel/core',
59 warn ERESOLVE     spec: '^7.0.0',
59 warn ERESOLVE     error: 'PEER LOCAL',
59 warn ERESOLVE     from: {
59 warn ERESOLVE       name: '@babel/helper-compilation-targets',
59 warn ERESOLVE       version: '7.22.5',
59 warn ERESOLVE       location: 'node_modules/@babel/helper-compilation-targets',
59 warn ERESOLVE       isWorkspace: false,
59 warn ERESOLVE       dependents: [Array]
59 warn ERESOLVE     }
59 warn ERESOLVE   },
59 warn ERESOLVE   dep: {
59 warn ERESOLVE     name: '@babel/core',
59 warn ERESOLVE     version: '7.22.5',
59 warn ERESOLVE     whileInstalling: {
59 warn ERESOLVE       name: '@babel/helper-compilation-targets',
59 warn ERESOLVE       version: '7.22.5',
59 warn ERESOLVE       path: '/Users/marklyck/web/ha-dash/node_modules/@babel/helper-compilation-targets'
59 warn ERESOLVE     },
59 warn ERESOLVE     location: 'node_modules/@babel/core',
59 warn ERESOLVE     isWorkspace: false,
59 warn ERESOLVE     dependents: [ [Object] ]
59 warn ERESOLVE   },
59 warn ERESOLVE   force: false,
59 warn ERESOLVE   isMine: false,
59 warn ERESOLVE   strictPeerDeps: false,
59 warn ERESOLVE   current: {
59 warn ERESOLVE     name: '@babel/core',
59 warn ERESOLVE     version: '7.21.4',
59 warn ERESOLVE     location: 'node_modules/@babel/helper-compilation-targets/node_modules/@babel/core',
59 warn ERESOLVE     isWorkspace: false,
59 warn ERESOLVE     dependents: [ [Object] ]
59 warn ERESOLVE   }
59 warn ERESOLVE }
60 timing idealTree Completed in 6655ms
61 timing command:install Completed in 6658ms
62 verbose stack TypeError: Cannot read properties of null (reading 'matches')
62 verbose stack     at Link.matches (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:1115:41)
62 verbose stack     at Link.canDedupe (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/node.js:1069:15)
62 verbose stack     at PlaceDep.pruneDedupable (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:426:14)
62 verbose stack     at PlaceDep.pruneDedupable (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:450:16)
62 verbose stack     at PlaceDep.pruneDedupable (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:444:14)
62 verbose stack     at new PlaceDep (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/place-dep.js:219:12)
62 verbose stack     at #buildDepStep (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:933:18)
62 verbose stack     at async Arborist.buildIdealTree (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:196:7)
62 verbose stack     at async Promise.all (index 1)
62 verbose stack     at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:159:5)
63 verbose cwd /Users/marklyck/web/ha-dash
64 verbose Darwin 22.5.0
65 verbose node v20.3.0
66 verbose npm  v9.7.2
67 error Cannot read properties of null (reading 'matches')
68 verbose exit 1
69 timing npm Completed in 6746ms
70 verbose unfinished npm timer reify 1687694684109
71 verbose unfinished npm timer reify:loadTrees 1687694684111
72 verbose unfinished npm timer idealTree:buildDeps 1687694690499
73 verbose unfinished npm timer idealTree:node_modules/@babel/helper-compilation-targets 1687694690742
74 verbose code 1
75 error A complete log of this run can be found in: /Users/marklyck/.npm/_logs/2023-06-25T12_04_44_022Z-debug-0.log