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

下载的React模板无法运行,执行npm run start报错求助

解决npm run start找不到package.json的问题

错误信息翻译

npm ERR! 代码 ENOENT
npm ERR! 系统调用 open
npm ERR! 路径 C:\Users\hp\Desktop\ReactIntroduction\material-kit-react-main\package.json
npm ERR! 错误码 -4058
npm ERR! enoent 无法读取package.json:错误:ENOENT: 没有该文件或目录,打开 'C:\Users\hp\Desktop\ReactIntroduction\material-kit-react-main\package.json'
npm ERR! enoent 这与npm无法找到文件有关。
npm ERR! enoent

排查与解决步骤

  • 确认终端工作路径
    打开终端,运行cd(Windows)或pwd(Linux/macOS),检查当前目录是否为C:\Users\hp\Desktop\ReactIntroduction\material-kit-react-main。如果不是,执行cd C:\Users\hp\Desktop\ReactIntroduction\material-kit-react-main切换到目标目录后再重试命令。

  • 检查package.json是否存在
    手动打开material-kit-react-main文件夹,确认里面有没有package.json文件。如果没有,说明模板下载不完整,要么重新下载完整的模板包,要么在目标目录运行npm init -y生成默认的package.json,之后手动添加start脚本:

    "scripts": {
      "start": "react-scripts start"
    }
    

    若使用react-scripts,需先执行npm install react-scripts --save安装依赖。

  • 不要手动复制node_modules
    直接复制node_modules容易导致依赖版本不匹配、路径错误。正确做法是确认package.json存在后,在目标目录运行npm install,让npm自动生成完整且匹配的node_modules和package-lock.json。

  • 检查文件夹权限
    确保当前用户对material-kit-react-main文件夹有读写权限。Windows下可右键文件夹→属性→安全,检查并添加当前用户的完全控制权限。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.07 02:04:59