ui icon indicating copy to clipboard operation
ui copied to clipboard

Shadcn not working in NextJS

Open piyush9808 opened this issue 1 year ago • 3 comments

Screenshot 2024-01-24 193321 Whenever I write this command after installing chad-cn while building a next-js project, I always encounter this error and chad-cn doesn't get initialised--

node:internal/modules/esm/resolve:214 const resolvedOption = FSLegacyMainResolve(packageJsonUrlString, packageConfig.main, baseStringified); ^

Error: Cannot find package 'C:\Users\piyush\AppData\Local\npm-cache_npx\125ee17d583c4e03\node_modules\wcwidth\package.json' imported from C:\Users\piyush\AppData\Local\npm-cache_npx\125ee17d583c4e03\node_modules\ora\index.js at legacyMainResolve (node:internal/modules/esm/resolve:214:26) at packageResolve (node:internal/modules/esm/resolve:840:14) at moduleResolve (node:internal/modules/esm/resolve:910:20) at defaultResolve (node:internal/modules/esm/resolve:1130:11) at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12) at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25) at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38) at ModuleWrap. (node:internal/modules/esm/module_job:85:39) at link (node:internal/modules/esm/module_job:84:36) { code: 'ERR_MODULE_NOT_FOUND' }

Node.js v21.4.0

I have already tried many fixes but it is still not working, reinstalled nodejs and still it didnt worked.

piyush9808 avatar Jan 24 '24 14:01 piyush9808

Have you followed the steps mentioned here? Try to start a new project while following the same steps.

ahmedsomaa avatar Jan 24 '24 21:01 ahmedsomaa

Yes I followed all the steps given here

piyush9808 avatar Jan 25 '24 17:01 piyush9808

What version of NextJS are you using? I followed the steps in the docs and it works for me. Also want to confirm your typing "shadcn-ui" and not "chadcn-ui" for the commands?

marcbrigham avatar Jan 28 '24 18:01 marcbrigham

This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.

shadcn avatar Feb 25 '24 23:02 shadcn

ive resolved this issue.put this on your terminal npm install shadcn-ui@latest and then npm install npx shadcn-ui@latest init it will start to work

tebogocodes avatar Mar 02 '24 07:03 tebogocodes

that worked for me

Ahmadmidlaj avatar Apr 04 '24 17:04 Ahmadmidlaj