Node Version Management
Node Version Manager (NVM) installation in Ubuntu 22.04
Install latest Node Version Manager (NVM)
// current version
https://github.com/creationix/nvm/releases
// installation
$ LATEST_VERSION=$(curl --silent "https://api.github.com/repos/nvm-sh/nvm/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
// v0.40.5
$ echo $LATEST_VERSION
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/${LATEST_VERSION}/install.sh | bash
CTRL^D, CTRL+ALT+T
$ nvm --version
0.40.5
Install latest LTS Node.js
// install latest LTS
$ nvm install --lts
$ nvm use --lts
$ node --version
v24.16.0
$ nvm install-latest-npm
or
-- show possible
$ nvm ls-remote
// (Latest LTS: Erbium)
$ nvm install v12.19.0
$ nvm use v12.19.0
-- set default
$ nvm alias default v12.19.0
$ node --version
v12.19.0
For fast switching
$ {
nvm install v20.15.0
nvm use v20.15.0
nvm alias default v20.15.0
}
$ {
nvm install v8.17.0
nvm use v8.17.0
nvm alias default v8.17.0
}
Yarn
$ npm install --global yarn
Possible additional configs
packages.json
"engines": {
"node": ">=12.13.1",
"npm": ">=6.13.4"
},
.npmrc
engine-strict=true
// Disable asking for money
$ npm config set fund false --location=global
// Specify registry
$ npm config set registry https://registry.npmjs.org/
$ npm get registry
$ npm config list
// example how to add your repo
$ vi .npmrc
registry=http://mylib.ru:8081/repository/npm-public-repo/
// If yarn will not create node_modules folder create with next content
$ vi .yarnrc.yml
nodeLinker: node-modules