fnm
The Fast Node Manager (fnm
) is a fast, cross-platform node version manager written in Rust. Earlier I was using nvm
On the Node.js download via package manager page, select the highest LTS
Node version, on Linux
and using fnm
to get a list of bash commands you’ll enter in the terminal:
Install fnm
:
curl -fsSL https://fnm.vercel.app/install | bash
View your Shell profile file (~/.zshrc
or ~/.bashrc
). It would’ve added the fnm
installation location to your PATH
as:
FNM_PATH="/home/kumar/.local/share/fnm"
if [ -d "$FNM_PATH" ]; then
export PATH="/home/kumar/.local/share/fnm:$PATH"
eval "`fnm env`"
fi
For Shell completions, refer their Shell setup section. For ZSH, add these lines at end of the file:
eval "$(fnm env --use-on-cd --shell zsh)"
Reload your shell to load those changes and activate fnm:
exec $(which $SHELL)
Install latest LTS Node.js version:
fnm install --lts
Verify Node.js installation:
node -v
npm -v
fnm
commandsfnm -h # Commands Help
fnm -V # Get FNM version
fnm list # or "fnm ls" to list your installed node versions
fnm list-remote # list all available remote node versions
fnm install 22 # install a specific node version
fnm current # node version you're currently using
fnm use 22 # switch to a node version
fnm use --install-if-missing 20 # install and use specific node version
fnm uninstall 22
We use
fnm
to install Node, andpnpm
as the package manager for our projects
pnpm
pnpm
is a fast, space-efficient package manager for Node. It re-uses packages across the node_modules/
folders of all your packages with the help of symlinks. It also has a robust lockfile management mechanism making dependency resolution much better, leading to faster downloads and builds
As per the pnpm Installation page. to install pnpm
on POSIX systems:
wget -qO- https://get.pnpm.io/install.sh | sh -
View your Shell profile file (~/.zshrc
or ~/.bashrc
). It would’ve added the pnpm
installation location to your PATH
as:
# pnpm
export PNPM_HOME="/home/kumar/.local/share/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
# pnpm end
Reload shell and verify pnpm
installed:
exec $(which $SHELL)
pnpm -v
pnpm
npm
vs pnpm
commandsnpm command | pnpm equivalent |
---|---|
npm install (all project packages) |
pnpm install |
npm install <package> (also -g or -D flags) |
pnpm add <package> |
npm run <scriptname> |
pnpm <scriptname> |
npx <package> |
pnpm dlx <package> |