当我尝试在 Next.js 应用程序中从 shadcn ui 添加组件时,遇到了以下错误。我从另一台设备开始这个项目,一切都很好。但在当前的设备中我遇到了这个错误。无法理解出了什么问题。
`npx shadcn@最新添加 toast 节点:内部/模块/esm/解析:204 constsolvedOption = FSLegacyMainResolve(pkgPath, packageConfig.main, baseStringified); ^
错误:找不到包 'C:\Users\user\AppData\Local pm-cache_npx\d66c5096c7023bfb ode_modules\is-regexp\index.js' 从 C:\Users\user\AppData\Local 导入 pm-cache_npx\d66c5096c7023bfb ode_modules\stringify-object\index.js 在legacyMainResolve(节点:内部/模块/esm/resolve:204:26) 在 packageResolve (节点:内部/模块/esm/resolve:846:14) 在 moduleResolve(节点:内部/模块/esm/resolve:926:18) 默认解析(节点:内部/模块/esm/解析:1056:11) 在 ModuleLoader.defaultResolve (节点:内部/模块/esm/loader:654:12) 在#cachedDefaultResolve(节点:内部/模块/esm/loader:603:25) 在 ModuleLoader.resolve (节点:内部/模块/esm/loader:586:38) 在 ModuleLoader.getModuleJobForImport (节点:内部/模块/esm/loader:242:38) 在 ModuleJob._link (节点:内部/模块/esm/module_job:135:49){ 代码:'ERR_MODULE_NOT_FOUND' }
Node.js v22.12.0 `
我的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" } }
我尝试过更新node和npm 当前版本: 节点:v22.12.0 npm:11.0.0
为了解决这个问题,我刚刚清除了 npm_cache,删除了文件夹中的所有内容 “C:\Users\用户\AppData\Local pm-cache_npx"