使用create-react-app创建React项目时遭遇ENOENT错误求助
使用npx create-react-app创建React项目时出现ENOENT错误
问题详情
执行以下命令创建项目:
npx create-react-app ./
触发如下错误:
npm ERR! code ENOENT npm ERR! syscall lstat npm ERR! path C:\Users\TOSHIBA\AppData\Roaming\npm npm ERR! errno -4058 npm ERR! enoent ENOENT: no such file or directory, lstat 'C:\Users\TOSHIBA\AppData\Roaming\npm' npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent npm ERR! A complete log of this run can be found in: C:\Users\TOSHIBA\AppData\Local\npm-cache\_logs\2023-07-30T04_29_09_680Z-debug-0.log
解决步骤
创建缺失的npm目录
打开文件资源管理器,导航到C:\Users\TOSHIBA\AppData\Roaming,手动新建名为npm的文件夹。重置npm前缀配置
以管理员权限打开命令提示符,执行:npm config set prefix "C:\Users\TOSHIBA\AppData\Roaming\npm"重新执行项目创建命令
再次运行:npx create-react-app ./备选方案(若上述步骤无效)
清除npm缓存后重试:npm cache clean --force
内容的提问来源于stack exchange,提问作者Adeniyi
相关产品推荐
相关产品推荐

