官术网_书友最值得收藏!

Installing React

Let’s try it by running yarn add react@15.6.1 from within your project folder.

We're installing a specific version of React (15.6.1) to ensure compatibility with other dependencies, and to ensure that there are no unexpected problems as new versions are released.

Once the installation is complete, you should see React added to our package.json under dependencies. You'll also see that yarn generated a node_modules folder and a yarn.lock file.

The node_modules folder is where all our packages will live. If you open it up, you can see that there are several folders already. We've not only installed React, but everything that React depends on--dependencies on dependencies.

As you might imagine, the node_modules folder can get quite hefty. So, we don't check it into source control. When a new developer joins the team and downloads the project files, they can then install the dependencies independently, based on the package.json; this saves time and space.

However, we need to ensure that they get the same packages as everyone else, and the same version; this is where the yarn.lock file comes in.

The previously mentioned setup ensures that we are ready to safely use third-party libraries. We have the package.json, yarn.lock, and node_modules folders in our project. Before we continue, let's ensure that adding React worked.

主站蜘蛛池模板: 墨脱县| 锦州市| 宜良县| 滨州市| 小金县| 台前县| 额济纳旗| 寿阳县| 贵南县| 涡阳县| 沁水县| 宣威市| 顺昌县| 民勤县| 谷城县| 司法| 合江县| 新竹县| 宁乡县| 玉田县| 将乐县| 鲁甸县| 崇文区| 滁州市| 谢通门县| 孙吴县| 太仆寺旗| 山东省| 沅江市| 曲阜市| 白朗县| 安西县| 高尔夫| 安岳县| 江永县| 闽侯县| 五大连池市| 房山区| 酒泉市| 海口市| 泰安市|