react:创建新项目

React中文官方文档给出创建新应用的最佳方式(命令行)。

npx create-react-app my-app
cd my-app
npm start

终端直接报错,提示如下:

bogon:~ jing$ npx creat-react-app myJob_react
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.com/creat-react-app - Not found
npm ERR! 404 
npm ERR! 404  'creat-react-app@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jing/.npm/_logs/2020-08-25T08_15_11_792Z-debug.log
安装 [ 'creat-react-app@latest' ] 失败,错误代码:1

根据提示应该是没有全局安装creat-react-app这个脚手架工具造成的,因此我们需要先安装creat-react-app这个脚手架工具造成,安装命令提示入下:

npm install -g create-react-app

但是,我本地这样也给我报错了,也是醉了。

npm ERR! code E503
npm ERR! 503 Service Temporarily Unavailable - GET https://cdn.npm.taobao.org/create-react-app/-/create-react-app-3.4.1.tgz
npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jing/.npm/_logs/2020-08-25T08_33_29_956Z-debug.log

研究了半天是npm 淘宝镜像的问题,换了几次镜像也没有安装成功,决定换个方式安装。使用 cnpm,使用之前先确认下是否安装cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org

cnpm -v
cnpm install -g create-react-app
cd my-app
npm start

中间还有很多曲折,在自己查看报错信息后一一对应安装,改正,总算开启了第一个react项目。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值