admin管理员组文章数量:1201804
I faced the error below when I tried to add components from the shadcn ui in my Next.js app. I started this project from my other device and there everything was fine. But in my current device I got this error. I can't understand what is wrong.
npx shadcn@latest add toast
node:internal/modules/esm/resolve:204
const resolvedOption = FSLegacyMainResolve(pkgPath, packageConfig.main, baseStringified);
^
Error: Cannot find package 'C:\Users\user\AppData\Local\npm-cache\_npx\d66c5096c7023bfb\node_modules\is-regexp\index.js' imported from C:\Users\user\AppData\Local\npm-cache\_npx\d66c5096c7023bfb\node_modules\stringify-object\index.js
at legacyMainResolve (node:internal/modules/esm/resolve:204:26)
at packageResolve (node:internal/modules/esm/resolve:846:14)
at moduleResolve (node:internal/modules/esm/resolve:926:18)
at defaultResolve (node:internal/modules/esm/resolve:1056:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:654:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:603:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:586:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:242:38)
at ModuleJob._link (node:internal/modules/esm/module_job:135:49) {
code: 'ERR_MODULE_NOT_FOUND'
}
Node.js v22.12.0
My package.json:
{
"name": "new",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev ",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@hookform/resolvers": "^3.10.0",
"@radix-ui/react-accordion": "^1.2.2",
"@radix-ui/react-alert-dialog": "^1.1.4",
"@radix-ui/react-label": "^2.1.1",
"@radix-ui/react-navigation-menu": "^1.2.3",
"@radix-ui/react-slot": "^1.1.1",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"framer-motion": "^12.0.0",
"lucide-react": "^0.473.0",
"next": "15.1.3",
"react": "^19",
"react-dom": "^19",
"react-hook-form": "^7.54.2",
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.24.1"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"@types/yandex-maps": "^2.1.36",
"eslint": "^9",
"eslint-config-next": "15.1.5",
"postcss": "^8.5.1",
"tailwindcss": "^3.4.17",
"typescript": "^5"
}
}
I have tried to update node and npm current versions: node: v22.12.0 npm: 11.0.0
I faced the error below when I tried to add components from the shadcn ui in my Next.js app. I started this project from my other device and there everything was fine. But in my current device I got this error. I can't understand what is wrong.
npx shadcn@latest add toast
node:internal/modules/esm/resolve:204
const resolvedOption = FSLegacyMainResolve(pkgPath, packageConfig.main, baseStringified);
^
Error: Cannot find package 'C:\Users\user\AppData\Local\npm-cache\_npx\d66c5096c7023bfb\node_modules\is-regexp\index.js' imported from C:\Users\user\AppData\Local\npm-cache\_npx\d66c5096c7023bfb\node_modules\stringify-object\index.js
at legacyMainResolve (node:internal/modules/esm/resolve:204:26)
at packageResolve (node:internal/modules/esm/resolve:846:14)
at moduleResolve (node:internal/modules/esm/resolve:926:18)
at defaultResolve (node:internal/modules/esm/resolve:1056:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:654:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:603:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:586:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:242:38)
at ModuleJob._link (node:internal/modules/esm/module_job:135:49) {
code: 'ERR_MODULE_NOT_FOUND'
}
Node.js v22.12.0
My package.json:
{
"name": "new",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev ",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@hookform/resolvers": "^3.10.0",
"@radix-ui/react-accordion": "^1.2.2",
"@radix-ui/react-alert-dialog": "^1.1.4",
"@radix-ui/react-label": "^2.1.1",
"@radix-ui/react-navigation-menu": "^1.2.3",
"@radix-ui/react-slot": "^1.1.1",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"framer-motion": "^12.0.0",
"lucide-react": "^0.473.0",
"next": "15.1.3",
"react": "^19",
"react-dom": "^19",
"react-hook-form": "^7.54.2",
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.24.1"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"@types/yandex-maps": "^2.1.36",
"eslint": "^9",
"eslint-config-next": "15.1.5",
"postcss": "^8.5.1",
"tailwindcss": "^3.4.17",
"typescript": "^5"
}
}
I have tried to update node and npm current versions: node: v22.12.0 npm: 11.0.0
Share Improve this question edited Jan 23 at 23:24 President James K. Polk 42k27 gold badges109 silver badges144 bronze badges asked Jan 21 at 12:23 Anvar AdizovAnvar Adizov 111 bronze badge 1 |1 Answer
Reset to default 0To fix this I just cleared npm_cache, just deleted everthing on folder "C:\Users\user\AppData\Local\npm-cache_npx"
本文标签: shadcnuiError while adding Shadcn component in Nextjs 15Stack Overflow
版权声明:本文标题:shadcnui - Error while adding Shadcn component in Next.js 15 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738635642a2104013.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
npm cache clean --force
, clearing yourpackage-lock.json
, and subsequently retrying. – Nicholas Dullam Commented Jan 21 at 18:06