执行npm start启动React应用时遇Cannot read properties of undefined错误
React应用npm start报错:Cannot read properties of undefined (reading 'stdin')
问题详情
执行npm start启动React应用时触发错误,报错信息如下:
saksh@DELL MINGW64 $ npm start sakshee@0.1.0 start react-scripts start npm ERR! Cannot read properties of undefined (reading 'stdin') npm ERR! A complete log of this run can be found in
已尝试重新安装Node.js和node_modules,问题未解决。相关package.json截图:
可行解决方案
- 切换终端环境:避免在IDE内置终端运行,改用系统原生终端(Windows用CMD/PowerShell,Mac/Linux用Terminal)重新执行
npm start。 - 清理npm缓存并重装依赖:
npm cache clean --force rm -rf node_modules package-lock.json # Windows系统替换为:rmdir /s /q node_modules && del package-lock.json npm install npm start - 更新react-scripts到最新版:
npm install react-scripts@latest npm start - 验证Node.js版本:确保使用的Node.js版本与react-scripts兼容(推荐LTS版本如18.x、20.x),版本不匹配则借助nvm/nvm-windows切换对应版本。
- 尝试用yarn启动:
npm install -g yarn yarn install yarn start
内容的提问来源于stack exchange,提问作者Sakshee
相关产品推荐
相关产品推荐

