Next.js集成ShadCN遇Bun缓存错误与安装失败问题求助
在Next.js项目中集成ShadCN时遇到Bun相关错误的解决方案求助
操作目标
- 使用
npx shadcn init初始化ShadCN - 通过
bun add tailwindcss-animate class-variance-authority lucide-react clsx tailwind-merge安装依赖 - 配置Tailwind CSS及导入别名
遇到的错误
Bun安装缓存错误
执行shadcn init时,Bun安装依赖报错:
error: moving "@ts-morph/common" to cache dir failed EPERM: Operation not permitted (NtSetInformationFile()) From: .df1fffffef2fbaae-00000007.common To: @ts-morph/common@0.19.0@@@1 error: InstallFailed extracting tarball from @ts-morph/common error: Failed to link shadcn: EBUSY
强制使用npm失败
执行npx shadcn init --package-manager npm时,报错:
error: could not find bin metadata file Bun failed to remap this bin to its proper location within node_modules. Please run 'bun install --force' in the project root and try it again.
手动安装依赖后重试仍报错
用npm install tailwindcss-animate class-variance-authority lucide-react clsx tailwind-merge手动安装依赖后,重试npx shadcn init仍出现Bun缓存问题。
已尝试的解决方法
- 清除Bun缓存:删除
C:\Users\<username>\AppData\Local\bun目录 - 以管理员身份执行命令
- 卸载并重新安装Bun
- 切换为npm,但
shadcn init仍默认使用Bun - 手动配置Tailwind及依赖
环境信息
- OS:Windows 11
- Node.js版本:20.15.1
- Bun版本:1.1.20
- Next.js版本:14.2.14
- ShadCN版本:2.1.0
求助问题
- 如何彻底阻止Bun干扰集成?能否为该项目全局禁用Bun?
- 有无Windows用户成功用npm集成ShadCN?需哪些配置或步骤?
- 是否可不依赖
shadcn init命令手动配置ShadCN?
内容的提问来源于stack exchange,提问作者Anshu Joshi
相关产品推荐
相关产品推荐

