Node.js, nvm, npm
nvm
Install: https://github.com/nvm-sh/nvm#install--update-script
| Command |
Action |
|---|---|
| nvm ls | see the Node.js versions you have installed via nvm |
| nvm install --lts | install LTS version (Long Term Support) — recommended for most users and production environments because it is more stable |
| nvm alias default 'lts/*' | set the LTS (Long Term Support) version as your global default so it persists across new terminal sessions |
npm
npm link auto-completion with @namespaces support
~/.zshrc:
# Initialize zsh completion system
autoload -Uz compinit
compinit
# Enable npm link completion for scoped packages
_npm_link_completion() {
local -a pkgs
pkgs=($(
{
find -L "$(npm root -g)" -mindepth 1 -maxdepth 1 -type d ! -name "@*"; \
find -L "$(npm root -g)/@"* -mindepth 1 -maxdepth 1 -type d; \
} | sed "s|$(npm root -g)/||"
))
_describe 'npm packages' pkgs
}
# Enable completion for 'npm link'
compdef _npm_link_completion npm link
Install local package with its dependencies
npm i <local-path> --install-links
npm explain
Introduced in npm v7, this command gives a clear, "bottoms-up" explanation of exactly why a package is in your node_modules tree and what requires it.
npm explain <package-name>
See also: