问题描述:
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