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

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.

主站蜘蛛池模板: 乌鲁木齐县| 库伦旗| 云龙县| 大石桥市| 南川市| 柳州市| 从江县| 德令哈市| 柯坪县| 丰台区| 奉化市| 临漳县| 禹州市| 滕州市| 汤原县| 沙河市| 谢通门县| 康平县| 综艺| 武乡县| 福泉市| 黄梅县| 大同市| 江津市| 乐至县| 娄烦县| 香港 | 大英县| 清水县| 吴桥县| 清水县| 广昌县| 鄂托克前旗| 龙井市| 中牟县| 永寿县| 比如县| 清丰县| 谢通门县| 崇义县| 昭通市|