react npm start报错

spawn *** ENOENT

今天使用creact-react-app创建react项目后使用npm start项目启动项目出现如下错误
在这里插入图片描述
然后百度查原因,发现遇到这个问题的挺多的,重新安装node、清理npm缓存、删除包重新npm install各种方法都试过了都不好使,差点准备放弃了,随后凭借我差点过四级的水平一波分析,觉得错误应该是在这里插入图片描述这个的问题,卵cmd错误??????查了下好像是环境变量的问题,cmd没有设置系统环境变量的问题,解决方案如下:

  1. 右键点击此电脑
  2. 选择属性->选择高级->点击环境变量
  3. 在系统变量PATH中添加 c:\windows\system32
  4. 重新npm start就成功运行了?

其他类似 spawn *** ENOENT 的错误也是没有添加相应的环境变量

npm start报错的其他问题解决方法

  1. 如果看见下面

    npm ERR! UpScore@0.6.0 start: react-scripts start
    npm ERR! spawn ENOENT

    意味着dependencies 时发生错误,可以做这三步:

    1. npm install -g npm@latest更新npm
    2. 移除node_modules包
    3. 重新npm install安装依赖
  2. 可能react-scripts没有在全局环境中

    方法:npm install -g react-scripts,或者在你的package.json中改变如下:

      "scripts": {
        "start": "./node_modules/react-scripts/bin/react-scripts.js start",
        "start:prod": "pushstate-server build",
        "build": "./node_modules/react-scripts/bin/react-scripts.js build",
        "test": "./node_modules/react-scripts/bin/react-scripts.js test --env=jsdom",
        "eject": "./node_modules/react-scripts/bin/react-scripts.js eject",
        "server": "cd client/api && pm2 start server.js --watch",
        "proxy": "http://128.199.139.144:3000"
      },
    
  3. npm install --save react react-dom react-scripts

  4. 有时你使用npm install -g npm@latest会出现如下错误:

    npm ERR! code ETARGET
    npm ERR! notarget No matching version found for npm@lates
    npm ERR! notarget In most cases you or one of your dependencies are requesting
    npm ERR! notarget a package version that doesn’t exist.

这时建议使用如下代替npm install -g npm@latest

	 npm i -g npm //which will also update npm
	 rm -rf node_modules/ && npm cache clean // to remove the existing modules and clean the cache.
	 npm install //to re-install the project dependencies.

总结

npm install安装依赖真的问题很多,而且很多时候你根本不知道啥问题,一天基本就忙这个问题上了,可能时不小心把环境变量删除了?

  • 6
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值