npm安装react出错npm install --no-audit --save --save-exact --loglevel error react react-dom react-script

问题描述:

Aborting installation.
npm install --no-audit --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
经过很多尝试发现在本电脑安装npx create-react-app my-app一直不成功!!!,但是用其他电脑没有任何问题,包括使用了一个重来没使用过的电脑,新下载node 然后执行npx create-react-app my-app都没有任何问题。然后看报错的日志说是我的npm 和node不匹配 ?天可怜见我对着了其他电脑一模一样,甚至重新安装node,却依旧不行,太气人了!!!
在这里插入图片描述
在这里插入图片描述

尝试过的方案:

Run: npm cache clean --force
Then Run:  npx create-react-app my-app
使用低版本node
nvm install 14  
Run: npm cache clean --force
Then Run:  npx create-react-app my-app
重新安装淘宝镜像
npm config set registry https://repo.huaweicloud.com/repository/npm/ 
npm cache clear --froce
npx create-react-app my-app
create-react-app需要升级版本
npm uninstall -g create-react-app
npm install -g create-react-app
npx create-react-app my-app

成功方案

// 卸载react
npm uninstall react react-dom 
// 全局安装
npm install -g create-react-app
// 查看版本号,确定create-react-app脚手架安装成功
create-react-app -V
// 使用脚手架创建my-app
create-react-app my-app
// 当我用create-react-app my-app创建成功以后,
//再次尝试npx create-react-app my-app以后也获得了成功
npx create-react-app my-app

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值