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

使用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

解决步骤

  1. 创建缺失的npm目录
    打开文件资源管理器,导航到C:\Users\TOSHIBA\AppData\Roaming,手动新建名为npm的文件夹。

  2. 重置npm前缀配置
    以管理员权限打开命令提示符,执行:

    npm config set prefix "C:\Users\TOSHIBA\AppData\Roaming\npm"
    
  3. 重新执行项目创建命令
    再次运行:

    npx create-react-app ./
    
  4. 备选方案(若上述步骤无效)
    清除npm缓存后重试:

    npm cache clean --force
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.15 02:10:59