Post

PNPM for NPM Users

If you’ve ever tried to make a web app using NodeJS, you might recall using something called npm. It is the package manager for NodeJS, and it allows you to install NodeJS packages quite easily without much effort. Installing a package is as simple as running npm install <package_name>. But sometimes, it can be quite slow and will get stuck in the install process. So I have decided to use an alternative to npm called pnpm. Although the name might sound similar (it does use npm under the hood), it’s much much faster than npm at installing packages and other package-related operations.

The following is a cheatsheet shows pnpm counterparts of some npm commands below, and I hope it would help npm users to use pnpm more easily:

npmpnpmDescription
npm installpnpm installInstall all dependencies
npm install <package_name>pnpm add <package_name>Install a specific package
npm install <package_name> --save-devpnpm add <package_name> --save-devInstall a package as a dev dependency
npm uninstall <package_name>pnpm remove <package_name>Uninstall a package
npm updatepnpm updateUpdate all dependencies
npm run <script>pnpm <script>Run a package.json script
npm initpnpm initInitialize a new package.json
npm cache clean --forcepnpm store pruneClear the package cache
npm listpnpm listList installed packages
npm outdatedpnpm outdatedShow outdated packages
npm publishpnpm publishPublish a package to the registry
npm cipnpm install --frozen-lockfileInstall dependencies from a locked file
npm install <package_name> --globalpnpm add <package_name> --globalInstall a package globally
npx <package_name>pnpm dlx <package_name>Execute a package without installing

For more commands, visit: PNPM docs or NPM docs

If you have any more suggestions please mail me at theonlyasdk@gmail.com! Thanks for reading!!

This post is licensed under CC BY 4.0 by the author.