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

无法使用npx create-react-app创建React应用的问题求助

无法使用npx create-react-app创建React应用的解决方案

问题描述

无法使用npx create-react-app创建React应用。尝试过卸载并重新安装Node.js,删除node_modules后重新安装React,但问题依旧。报错信息如下:

node:internal/modules/cjs/loader:1075
throw err;
^

Error: Cannot find module 'C:\Users\heman\node_modules\create-react-app\index.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1072:15)
at Module._load (node:internal/modules/cjs/loader:925:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

Node.js v20.3.1

解决步骤

  • 清除npx缓存,避免损坏的缓存文件干扰:

    npx clear-npx-cache
    
  • 强制使用最新版create-react-app执行创建命令,绕过本地可能存在的异常缓存:

    npx create-react-app@latest my-app
    
  • 卸载全局安装的create-react-app(如果之前安装过),避免版本冲突:

    npm uninstall -g create-react-app
    

    执行完后再重新运行npx create-react-app my-app。

  • 检查权限问题:Windows系统下尝试以管理员身份打开终端,Mac/Linux下可在命令前加sudo,确保模块安装时有足够权限。

  • 切换npm源到国内镜像,解决网络导致的模块下载不完整问题:

    npm config set registry https://registry.npmmirror.com/
    

    设置完成后再次执行创建命令。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 17:52:03