Mac下react安装

检查node是否安装

没有安装可到官网进行下载   Node.js

安装完成后在终端输入npm -v检查是否安装完成

安装react

设置npm源

npm config set registry https://registry.npm.taobao.org --global
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/etc
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/etc'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/etc'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/etc'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/zhanwei/.npm/_logs/2020-04-29T15_10_56_578Z-debug.log

出现以下错误说明权限不足

解决权限不足的方法

打开终端输入下列命令

mkdir .npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
PM_CONFIG_PREFIX=~/.npm-global

解决后设置npm源

npm config set registry https://registry.npm.taobao.org --global

npm config set disturl https://npm.taobao.org/dist --global

安装全局create-react-app

npm install -g create-react-app

出现下面情况说明安装成功

npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
/Users/yangkui/.npm-global/bin/create-react-app -> /Users/yangkui/.npm-global/lib/node_modules/create-react-app/index.js
+ create-react-app@4.0.3
added 67 packages from 25 contributors in 2.814s

创建项目

cd到你要创建项目的文件夹内输入命令

create-react-app 项目名称

运行项目

cd到刚创建的项目文件夹内运行

npm start

出现以下节目什么运行成功

 完毕

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值