第一步:
$ sudo npm install -g create-react-app
为了减少报错可能,直接上最高权限sudo,全局安装脚手架工具。(会提示让你输入密码)
第二步:
create-react-app frist-app
frist-app为你的项目名,
如果你是天选之子,这步之后直接创建成功了,那么接下来的你都可以不用看了。
第三步:
我到这里报错了,说是少了个什么pkg-config.....无奈,装!
npm ERR! code 1
npm ERR! path /Users/chenbingxiang/wuziqi/react-test-demo/node_modules/canvas
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! (node:58942) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
npm ERR! (Use `node --trace-deprecation ...` to show where the warning was created)
npm ERR! /bin/sh: pkg-config: command not found
npm ERR! gyp: Call to 'pkg-config pixman-1 --libs' returned exit status 127 while in binding.gyp. while trying to load binding.gyp
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack at ChildProcess.onCpExit (/Users/chenbingxiang/wuziqi/react-test-demo/node_modules/node-gyp/lib/configure.js:351:16)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:394:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 20.4.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/Users/chenbingxiang/wuziqi/react-test-demo/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /Users/chenbingxiang/wuziqi/react-test-demo/node_modules/canvas
npm ERR! gyp ERR! node -v v16.3.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/chenbingxiang/.npm/_logs/2021-07-12T05_29_07_256Z-debug.log
brew install pkg-config
查了半天可以用brew去下载这个东西,而brew本身自己网站就有一些问题,所以装起来非常费劲找了一个不错的教程
https://www.jianshu.com/p/e0471aa6672d?utm_campaign=hugo
这里头大博主教了怎么装这个Homebrew。
第四步
装完别忘了回过头来,因为你刚装完是一个默认的下载源,如果你直接用来下载接下来的东西,要么很慢要么干脆找不到,俺妈教我,这条路走不通,就换!!直接换源
cd $(brew --repo)
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
cd $(brew --repo)/Library/Taps/homebrew/homebrew-core
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
换完这个brew 源之后,就重新更新一下库,有大佬说这个源可以自己创一个git仓库,然后下载到这里头,但是我觉得这样太麻烦了如果brew更新了你也得手动,哎,可惜我也不会别的,hhh那就用中科的吧。
brew update
执行完上面这步之后大概长下面这样。你就算是更新完了,在这个过程中只有头部的title会有时候变一下。
Updated 2 taps (homebrew/core and homebrew/cask).
==> New Formulae
amfora haruhi-dl phpbrew
archey4 himalaya pillow
argocd-autopilot imath plow
argocd-vault-plugin ipinfo-cli principalmapper
at-spi2-atk jello proj@7
at-spi2-core jrsonnet pure
atuin julia px
autoconf@2.69 kalker pyflow
autorestic ki pythran
avahi kick
。。。。。。。。。。。。。。。。。
You have 7 outdated formulae installed.
You can upgrade them with brew upgrade
or list them with brew outdated.
然后我们接着下载
brew install pkg-config
结果大概长下面这样
Updating Homebrew...
==> Downloading https://ghcr.io/v2/homebrew/core/pkg-config/manifests/0.29.2_3
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/pkg-config/blobs/sha256:0040b6e
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Pouring pkg-config--0.29.2_3.big_sur.bottle.tar.gz