PNPM - The minified NPM

Posted on: March 20, 2019

Share:
LinkedIn
Reddit
WhatsApp

In this present world of web development, almost everyone might have heard the word

node_modules

They are very popular. They came with lot of advantages over CDNs. They made offline development possible. They made web development much easier and faster.

But, node_modules come with a con. They occupy space.. A lot of space. For e.g. create-react-app alone occupies ~232MB of disk space. They are making offline development possible and hence this overhead looks fine. I was happy with nodemodules until I noticed some pattern one day. I have over 30 projects on my Laptop and nodemodules alone occupied 8-10GB of my space. This made me think. Why we should have the exact copy of node_modules in every project I created. Don’t we have a provision to store everything at a single location and refer them from there.So, I started exploring and that lead me to PNPM.

pnpm

pnpm is an efficient solution to above discussed problem. It installs the required package only once in a common place and whenever we install that package in any project using npm install package-name, a hard link will be placed within node_modules folder of the project instead of installing package there. This way, it maintains only one version of each module and can effectively save lot of space in the long run.

USAGE

  • installation

    npm install -g pnpm

    It’s as simple as that. Usage is also pretty simple. It is very easy to get switched to pnpm from npm or yarn because the commands are still gonna be the same.

    pnpm run dev

    pnpm install packageName

    pnpm run build

    etc..

Added advantage

pnpm comes with an added benefit apart from saving space. It is faster than npm & yarn. See the benchmark results here

Overall, I’m having great experience using pnpm. Hope you guys also like using it.

If you found the article useful, please like, share and subscribe to my newsletter. That motivates me to write more..!

edit this page on github


Written by Kirankumar Ambati who lives and works in Hyderabad. Twitter Linkedin Github

Be the first one to be notified when I write a new article.

Crafted with Love by Kirankumar.