Package management npm, yarn, pnpm difference

npm

npm is the standard package manager for Node.js, installed along with node.js.
Deficiencies:

1. npm install Slow download speed .

2. For the same project, the installation cannot maintain consistency . The reason is that the version number in the package.json file has different meanings during installation. ^ is the default symbol after npm installation.

insert image description here

3. When using npm to install multiple js packages, the packages will be downloaded and installed at the same time. During the installation process, one of the packages throws an exception, but npm will continue to install other packages, so the error message will be lost in a large number of prompt messages, so that the actual error will not be found until the execution .

Yarn

Yarn emerged to make up for some of the shortcomings of npm. It is a new JS package management tool jointly launched by Facebook, Google, Exponent and Tilde.

The difference between npm and yarn

1. Parallel installation: The yarn installation package will execute multiple tasks at the same time, and npm needs to wait for the installation of the previous task to complete before running the next task.

2. Offline mode: If you have already installed a package, installing it again with yarn will get it from the cache, and npm will download it from the network.

3. Version lock: yarn has a yarn.lock file lock version by default. Before using npm or yarn to install, it will check the version on the lock file and install them to ensure a unified environment. By default, npm downloads the latest version from the Internet. Stable, version locking can solve the problem of version incompatibility between packages, and npm can also implement version locking through commands.

4. More concise output: when yarn installs packages, it outputs less information, while npm outputs redundant information.
insert image description here

pnpm

pnpm (performant npm), means "high-performance npm". Derived from npm/yarn, pnpm solves potential bugs inside npm/yarn, greatly optimizes performance, and expands usage scenarios. Known as "the most advanced package management tool".
Advantage:

  • Package installation is fast . pnpm is not only faster than npm, but also faster than yarn. It is faster than yarn for both cold and warm caches. yarn copies files from cache, while pnpm just links them from global storage.
  • Efficient use of disk space . All files are stored somewhere on your hard drive. When the package is installed, the files in the package are hard-linked to this location without taking up additional disk space.

Guess you like

Origin blog.csdn.net/weixin_43288600/article/details/121304220