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

使用create-react-app创建TS项目后npm start报错:Cannot read properties of undefined (reading 'stdin')

解决方案:npm ERR! Cannot read properties of undefined (reading 'stdin')

1. 检查终端交互性

这个错误大多和终端无法正常访问stdin有关,比如在非交互式环境(部分IDE内置终端、后台脚本)运行命令,或是终端权限异常。

  • 切换到系统原生终端(Windows用CMD/PowerShell,macOS/Linux用Terminal),重新执行npm start
  • 如果用IDE终端,确认开启了交互式模式,比如VS Code可通过终端面板右上角下拉菜单选择「新建终端」,确保是交互式会话

2. 清理缓存并重装依赖

缓存损坏也可能引发这类异常:

  • 执行命令清除npm缓存:npm cache clean --force
  • 删除项目根目录下的node_modules文件夹和package-lock.json文件
  • 重新安装依赖:npm install
  • 再次尝试启动项目:npm start

3. 降级npm版本

npm 9.x与Node 18.x部分组合存在兼容性问题,可降级到稳定版本:

  • 全局降级npm:npm install -g npm@8.19.4(该版本和Node18适配性较好)
  • 返回项目目录,重新安装依赖后启动

4. 更新create-react-app后重建项目

可能是模板版本问题,尝试用最新版create-react-app重新创建项目:

  • 卸载全局create-react-app:npm uninstall -g create-react-app
  • 执行最新创建命令:npx create-react-app@latest my-app --template typescript
  • 进入新创建的项目,执行npm start

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.12 20:45:54