React 源码阅读 - 环境准备

# React 源码阅读 - 环境准备

阅读源码之前, 先把准备工作做好~

# 下载代码

# --depth=1 只会下载最后一个 commit 关联的 object,下载内容更少,速度会快很多
git clone https://github.com/facebook/react.git --depth=1
1
2

# 安装依赖

yarn
1

安装中出现了一个问题

error /react/node_modules/gifsicle: Command failed.
Exit code: 1
Command: node lib/install.js
Arguments: 
Directory: /react/node_modules/gifsicle
Output:
⚠ connect ECONNREFUSED 0.0.0.0:443
  ⚠ gifsicle pre-build test failed
  ℹ compiling from source
  ✖ Error: Command failed: /bin/sh -c autoreconf -ivf
/bin/sh: autoreconf: command not found

    at /react/node_modules/bin-build/node_modules/execa/index.js:231:11
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

使用 brew 安装解决

brew install autoconf automake libtool
1

安装后重新执行 yarn 进行安装即可

# 参考链接