pnpm init- Create new package.json with default values
pnpm add <package>- Install a package locallypnpm install- Install all deps from package.jsonpnpm add react@18- Install specific version
pnpm remove <package>- Remove a dependencypnpm update- Update all dependenciespnpm update <package>- Update a specific dependency
pnpm run <script>- Run a script
pnpm store path- Show global store pathpnpm store status- Show store healthpnpm prune- Remove unused packages
pnpm list- Show installed dependenciespnpm list --depth 0- Show top-level packages onlypnpm why <package>- Check why package is installedpnpm outdated- Show outdated dependencies
pnpm install --force- Reinstall everything freshly
| Task | npm | pnpm |
|---|---|---|
| Install dependency | npm install pkg |
pnpm add pkg |
| Install dev dependency | npm install -D pkg |
pnpm add -D pkg |
| Install globally | npm install -g pkg |
pnpm add -g pkg |
| Remove dependency | npm uninstall pkg |
pnpm remove pkg |
| Run script | npm run dev |
pnpm dev |
π Tip:
Use
pnpm addinstead ofpnpm install <pkg>
It is the recommended and clean syntax.