You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Vite项目执行npx shadcn-ui@latest init时出现npm ERR! code ENOENT错误?

解决npx shadcn-ui init时的ENOENT错误

执行npx shadcn-ui@latest init时出现以下错误:

npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path C:\Users\user\AppData\Roaming\npm
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'C:\Users\user\AppData\Roaming\npm'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

解决步骤:

  • 手动创建缺失的目录:打开文件资源管理器,进入C:\Users\你的实际用户名\AppData\Roaming路径,新建名为npm的文件夹。
  • 配置npm前缀路径:打开CMD或PowerShell,执行命令:
    npm config set prefix "C:\Users\你的实际用户名\AppData\Roaming\npm"
    
  • 清理npm缓存:
    npm cache clean --force
    
  • 重新执行shadcn初始化命令:
    npx shadcn-ui@latest init
    

如果创建目录或执行命令时遇到权限问题,右键以管理员身份打开CMD/PowerShell再操作。

内容的提问来源于stack exchange,提问作者Being47

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 12:02:42