使用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
相关产品推荐
相关产品推荐

