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

无法正常安装React求助:执行npx create-react-app时出现ENOENT错误

React项目创建失败(ENOENT错误)解决方案

问题描述

执行npx create-react-app employee_app创建React项目时出现以下错误:

C\Windows\System32\cmd.e X +
Microsoft Windows [Version 10.0.22621.2715] (c) Microsoft Corporation. All rights reserved.
C:\Users\user\Desktop\React>npx create-react-app employee_app
npm ERR! code ENOENT
npm ERR! syscall Istat
npm ERR! path C:\Users\user\AppData\Roaming\npm
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, Istat 'C:\Users\user\A ata\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\user\AppData
ocal\npm-cache_logs\2023-12-22T17_12_07_950Z-debug-0.log
C:\Users\user\Desktop\React>

已确认Node.js和npm为最新版本,但无法完成安装。

解决步骤

  • 检查并创建缺失目录

    1. 打开文件资源管理器,开启「显示隐藏项目」选项(在「查看」菜单中)
    2. 导航到C:\Users\user\AppData\Roaming路径
    3. 若该路径下无npm文件夹,手动创建一个
  • 重置npm配置

    1. 以管理员身份启动命令提示符(CMD)
    2. 执行命令:npm config set prefix "C:\Users\user\AppData\Roaming\npm"
    3. 清理npm缓存:npm cache clean --force
  • 重新创建项目
    返回目标目录,再次执行npx create-react-app employee_app。若仍失败,可尝试使用Vite替代:

    npm init vite@latest employee_app -- --template react
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.03 14:22:15