Please enable Javascript to view the contents

react cli 常见错误

 ·  ☕ 1 分钟

错误 1. ‘react-scripts’ 不是内部或外部命令

问题详情:‘react-scripts’ 不是内部或外部命令,也不是可运行的程序 或批处理文件。

解决办法:

重新安装 react-scripts

yarn add react-scripts

cao,重装真TMD的够慢的。

错误 2. 无法创建react 项目

今天通过npx、 yarn 方式都无法创建react项目。

npx create-react-app my-app
yarn create react-app my-app

以上两个常规创建react项目都不行。

检查了一番,发现可能这台机器没有装 create-react-app这个命令。安装即可:

$ yarn global add create-react-app
$ create-react-app my-app

错误3. info There appears to be trouble with your network connection. Retrying…

在安装 material-ui时,遇到以下问题:

info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
error An unexpected error occurred: "https://registry.npm.taobao.org/@material-ui/types/download/@material-ui/types-5.1.0.tgz: ESOCKETTIMEDOUT".

分析问题,关键词 ESOCKETTIMEDOUT。

搜索之后,解决办法如下,首先:

npm config rm proxy
npm config rm https-proxy

然后,再编辑 .yarnrc 文件,添加配置:

network-timeout 600000

或者

yarn add <yourPackage> --network-timeout 600000

如果不够,数值可以再加大 。

小问题,持续更新…

参考资料

分享

码中人
作者
码中人
Web Developer