Будем использовать NVM
sudo apt-get install build-essential libssl-dev wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash # see https://github.com/creationix/nvm#install-script for latest version available # choose latest LTS, like Carbon, and install latest version of this LTS nvm install --lts nvm alias default lts/* # update NPM to latest stable version npm install npm@latest -g
this is not enough tested
# show currently installed version of NodeJS - remember it! nvm current # now view LTS version available nvm ls-remote --lts # for example, latest LTS is Carbon nvm install --lts=carbon # now set default version as this LTS (instead of 8 you may use more specific version, like v8.10.0 - check by nvm alias) nvm alias default 8 nvm use default # update NPM npm install npm@latest -g npm cache clean # update global packages (in this example from nvm 6.13.1 - see begginning of this instruction) nvm reinstall-packages v6.13.1 # update global packages (is it needed?) npm update -g
show current version of NodeJS
nvm current
show installed version of NodeJS
nvm ls
show installed version of NPM
npm -v