Notes on pnpm
This page is managed by StJohn Piano.
If you have any questions, comments, or suggestions - please contact StJohn Piano on Tela:
tela.app/id/stjohn_piano/7c51a6
Introduction
pnpm
stands for performant npm
Main focus: Save disk space
When using npm, if you have 100 projects using a dependency, you will have 100 copies of that dependency saved on disk.
With pnpm, the dependency is stored in a global content-addressable store.
If you install a dependency in a project, pnpm creates a hard link to its global store within the project's node_modules
directory.
Hard links point to the same place on the disk where the original files are. So: There is only one global copy of the dependency.
More detail
If you depend on different versions of the dependency, only the files that differ are added to the store. For instance, if it has 100 files, and a new version has a change in only one of those files, pnpm update
will only add 1 new file to the store, instead of cloning the entire dependency just for the singular change.
Install
Manage NodeJS versions
pnpm env --help
List available versions of npm:
pnpm env list --remote
Install and set an npm version:
pnpm env use --global 18
You can use the lts
modifier to install the LTS version.
pnpm env use --global 18 lts
Install an npm version (but do not set it):
pnpm env add --global 20 lts
Set version:
pnpm env use --global 20
Double-check:
admin@horizon contract-toolset % node --version
v20.11.0
Manage repository dependencies
pnpm list
pnpm install
(installs the dependencies in package.json
)
Configuration
See global store location:
pnpm store path
Sources
Follow Tela Network on LinkedIn:
linkedin.com/company/tela-network
Follow Tela Network on Twitter:
twitter.com/tela_updates
Join Tela Network and become a consultant:
tela.network/join
Join the Tela Social channel on Telegram to get every new update:
t.me/tela_social
Follow Tela Network on Instagram:
instagram.com/tela_updates