Yesterday I saw a discussion on PNPM in a group, I thought I can really make wheels in front of the front end, what is it? I tried it and found it really sweet, now I can’t stop, this tool helps me release a lot of disk space, I strongly recommend you to try it!

1. What does PNPM do?

  • It’s official: fast, disk space saving package management tool
  • The same package management tool as NPM and YARN

Website PNPM. IO/useful /

2. What problem does PNPM solve?

  • Save disk space and speed up installation
  • Create a non-flattened node_modules folder

IO/en /motivati…

3. Advantages of PNPM

  • Fast: 2x faster than the alternative
  • Efficient: Files in Node_modules are linked from a single content-addressable store
  • Support for Monorepos: PNPM has built-in support for single warehouse and multiple packages
  • Strict: PNPM creates a non-tiled node_modules, so code cannot access arbitrary packages

Still a little confused see: mp.weixin.qq.com/s/aCS4Ku34n…

4. How to convert from NPM to PNPM?

4.1 Conversion is very simple and the steps are as follows:

  1. Delete the node_modules directory and package-locked.json in the project directory
rm -rf ./node_modules package-lock.json
Copy the code
  1. Global install PNPM, do not want to global install NPX can also be used
npm i -g pnpm
Copy the code
  1. Perform the PNPM installation in the project directory
pnpm install
Copy the code

or

npx pnpm install
Copy the code

4.2 Precautions

  • For example, if the main taro version is 3.2.10, the related taro package version should also be 3.2.10
  • PNPM depends on node 14 or later. You need to upgrade node 14 or later

Further reading

  • PNP reference of YARN
  • Deep thoughts on modern package managers — why do I now recommend PNPM over NPM/YARN?