Dependencies with yarn / npm version management

In package.json are basically used to lock version ^, ^ can lock large version 2.6.1 ^ example, installation can only be determined to be> 2.0.0 <2.9.9, and if has been updated to 2.9.1 version, it will download the 2.9.1 version. This will exist when inconsistent versions and development versions of installation problems, it is likely other colleagues of the project, no problems, only your project or start page has a strange error.

To solve this problem, we can replace the yarn npm

yarn install automatically generates a yarn.lock document, which states that each version of the installation package is now installed, each time with the yarn after reinstalling dependent, will give priority in yarn.lock download version. This ensures that each co-worker on the same version developed.

So if we want to manually update a package's version of it? For example package.json the element-ui ^ version is 2.6.1, we want to use version 2.9.1.

Execute the command: yarn upgrade [email protected] 

package.json version 2.9.1 will be specified, and yarn.lock also updated so that other colleagues in the development and re-execute the next yarn install, will be updated to the specified version.

 

Of course, if you still want to use npm complete version of the lock function it is also possible, but to use 5 or later, and npm install very slow, even if the configuration Taobao source, is still very slow, so I gave up.

Try the next cnpm install, find and does not generate packgae-lock.json files on the Internet to find information that is cnpm install and does not generate a lock file, and, even if there are lock files in the project, cnpm not read the file , only by package.json download, so cnpm version does not support locking. Of course, this is only hearsay, if someone tried to tell me also please leave a message, in which I stole a lazy. Because it is too slow, cnpm install is often socket hang up.

Guess you like

Origin www.cnblogs.com/lijianjian/p/11040279.html