ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

macOS创建react项目!!!

2021-07-13 10:02:06  阅读:288  来源: 互联网

标签:npm node macOS ERR 创建 app react gyp brew


第一步:

$ 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

标签:npm,node,macOS,ERR,创建,app,react,gyp,brew
来源: https://blog.csdn.net/weixin_45885731/article/details/118681896

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有