Transcript for:
npm vs. pnpm Overview

npm plays a pivotal role in streamlining mine and probably your JavaScript projects npm has long been my go-to choice and I mean it's all right like overrated as.. but I recently made the switch to pnpm the proficient npm. npm's flattened directory structure seemed like a step in the right direction from its version 3 release however I'm not gonna fall for that smooth brain Flat Earth theory structure enter PNPM with its little friends called symbolic and hard links if you don't know what hard links and sym links are, say I create a file, index.html. My file system will point this file to what is called an inode and the inode contains all of the metadata and links to the data blocks that contain the contents of this file. A hard link is a direct link to that inode whereas a sym link is a reference to the index.html file. pnpm takes the packages I choose to install and creates hard links to a flattened Global store directory while storing sym links within. This approach not only ensures strict access only to the packages I need but also eliminates the slow copy pasting of packages between projects like npm doe. The Result? A faster, cleaner and more organized development environment. What about peer dependencies? Peer dependencies are a puzzle that can leave even seasoned developers scratching their heads. yeah I'd like to solve the puzzle pnpm solves this *puzzle* through an elegant hoisting mechanism. All dependencies including peer dependencies are hoisted to the dot pnpm node modules directory this means a single unified node modules directory houses all the dependencies making management a breeze pnpm's smart resolution process scans the entire chain of node module directories upward to locate a compatible version of a peer dependency additionally the magic of a shared peer dependencies accomplished through hard links and further reduces duplication of files and enhances the efficiency of my projects. What about performance while npm copies packages across projects pnpm's linking approach creates hard links to the shared package in the global store the result is a blazingly fast installation and update time saving me valuable development hours because you know hours are scarce. moreover pnpm's disk space usage is impressively low as it effectively shares packages across projects this not only reduces data duplication but also optimizes my disk space usage a win-win situation if you ask me. So how do you actually install pnpm? Installing pnpm with npm and node.js already installed is as simple as using npm install -g pnpm for a global installation. Installing pnpm without npm or node.js is as simple as opening your command line of choice and typing something like the following. PNPM is very similar to npm as it still has the same install command but the shorthand of the install command is pnpm add instead of npm i. Running scripts from the package.json file is as simple as using pnpm with the script tag. Apart from the detrimental one extra character typed every time you go to use a pnpm command there are a couple of limitations to using pnpm over npm. If you already have an npm project, the npm-shrinkwrap.json and package-lock.json are ignored because npm's lock file was designed for the flattened node modules layout meaning that pnpm will ignore it. There is however a pnpm import command which generates a pnpm-lock.yaml file from one of the following source files. My switch from npm to pnpm has been a revelation. I'm constantly on the lookout for the most bleeding edge solutions to enhance my extreme developer workflow and keep that cool and good knowledge every developer strives for. pnpm's proficiency, performance and efishency have elevated my development experience allowing me to focus on what truly matters, crafting exceptional projects with ease and precision. Like or dislike pnpm? Check out the docs in the description if you're not convinced and tell me why down below so I can scrape your data and spend weeks hyper obsessing over the intricate details via graphs relating to pnpm until my new ADHD obsession kicks in I'll leave yet another project abandoned