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

运行npx create-react-app出现ENOENT错误,请求解决方案

解决npx create-react-app my-app执行时的ENOENT错误

问题详情

执行命令:

npx create-react-app my-app

遇到以下错误:

npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path C:\Users\dejean\AppData\Roaming\npm
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'C:\Users\dejean\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:
npm ERR!     C:\Users\dejean\AppData\Local\npm-cache\_logs\2023-06-27T18_53_22_682Z-debug-0.log

当前环境:Node.js 18.16.1,npm 9.5.1

解决方案

  • 手动创建缺失的npm目录
    打开CMD(普通用户身份即可),执行命令创建目录:

    mkdir "C:\Users\dejean\AppData\Roaming\npm"
    
  • 重新全局安装npm
    执行命令修复npm安装结构:

    npm install -g npm
    
  • 清理缓存后重试创建项目
    先清理npm缓存:

    npm cache clean --force
    

    之后再次运行创建命令:

    npx create-react-app my-app
    
  • 检查并配置环境变量

    1. 右键「此电脑」→「属性」→「高级系统设置」→「环境变量」
    2. 在「用户变量」的Path中,确认是否包含C:\Users\dejean\AppData\Roaming\npm,无则添加该路径
    3. 保存后重启命令提示符再尝试操作

内容的提问来源于stack exchange,提问作者H-Bar

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 23:43:29