I have always used npm install or cpmp install to install dependencies. Later, yarn was recommended by many people. It seems that yarn is much more reliable than npm and cpmp, but I don’t know the reason. I checked a lot of related information, but there is no Not convincing. May I ask the master to show up and help clear up the confusion?
PHP中文网2017-05-16 13:40:00
npm: npm is the official package management of node. Some personally developed packages can be uploaded through the relevant commands of npm, and others can be downloaded through the corresponding commands.
cnpm: Due to the domestic firewall, downloading content through npm will encounter problems such as failure or slow speed. Taobao has synchronized a set of domestic images of all packages on npm. Due to domestic reasons, the domestic download speed is very fast. Fast, except that the package cannot be published through cnpm, there is no difference from the other npm commands.
yarn: The main difference between it and npm is mainly reflected in yarn.lock. If there is no yarn.lock
的话,就会新建这么一个文件,并且锁定对应包的版本,如果当前项目根目录下有 yarn.lock
in the project root directory, the version packaged in yarn.lock will be installed. For the version installed through the npm package, unless it is hard-coded in package.json, there is a risk of dynamic changes. Secondly,
yarn can be installed offline and is faster.