Node.js (nvm)
Installthe Node Version Manager (
)gitnvm
yoursudotopacmaninstall-SNode.jsgitinto current Installuser'sVisual Studio Codepath and switch Node.js versions on the fly.Install
nvm
fromviaAURthe AUR:yay -S
visual-studio-code-binnvmAdd
the init scriptnvmto/usr/share/nvm/init-nvm.sh
into your shellrcconfigurationfileto load it each time you start your terminal:# bash echo 'source /usr/share/nvm/init-nvm.sh' >> ~/.bashrc # zsh echo 'source /usr/share/nvm/init-nvm.sh' >> ~/.zshrc
Installyour terminal to reload all init scripts and you should be able to usenvm
to install a Node.js,jse.g.versionNodeofv12your choice:nvm install 12
Use
Include
Restart
Migrating
npm
packages
When you install and switch to a different nvm
managed version of Node.js (nvm install 14
or nvm use 16
) you may find that your globally installed npm
packages (e.g. svgo
) are no longer available until you switch back to the specific version of Node.js you have been using before the upgrade or switch.
This is because globally installed npm
packages are installed for the specific version of Node.js you happen to be using at the time of installation and placed in a directory i.e. ~/.nvm/versions/node/v16.14.0/lib/node_modules
. When you install a different version, e.g. 17.2.0
the path to your Node.js installation changes to ~/.nvm/versions/node/v17.2.0/lib/node_modules
.
Use the --reinstall-packages-from=<version>
option to carry over globally installed packages to the new Node.js installation.
You can either pass a specific version you want to reinstall globally installed packages from or use bash string expansion to reinstall from the currently active one in use:
nvm install <new version> --reinstall-packages-from=<old version>
nvm install 17 --reinstall-packages-from=$(node -v)