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

执行npx create-react-app创建React项目时遇模块找不到错误求助

解决Create React App创建项目时的"Cannot find module"错误

你遇到的错误 ERROR: Cannot find module. Please verify that the package.json has a valid "main" entry. 大概率是npx缓存了损坏的create-react-app包,或者全局安装的版本和npx拉取的版本冲突导致的,试试下面的解决步骤:

  • 先清理npx的本地缓存,避免加载损坏的旧包:

    npx clear-npx-cache
    
  • 强制使用最新版create-react-app创建项目,指定版本号跳过缓存:

    npx create-react-app@latest my-app
    
  • 如果之前全局安装过create-react-app,可能会和npx的临时版本冲突,先卸载全局版本:

    npm uninstall -g create-react-app
    

    卸载后再重新执行创建命令即可。

  • 检查npm镜像源是否同步异常,临时切换回官方源试试:

    npm config set registry https://registry.npmjs.org/
    
  • 若以上方法都无效,清理npm全局缓存后重试:

    npm cache clean --force
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.17 21:05:50