Node.js (nvm)
Use
gitnvm) sudoto pacmaninstall -SNode.js gitinto your current Install nvm fromvia AURthe AUR:
yay -S visual-studio-code-bin nvm
Include
nvmthe init script /usr/share/nvm/init-nvm.sh into your shell # bash
echo 'source /usr/share/nvm/init-nvm.sh' >> ~/.bashrc
# zsh
echo 'source /usr/share/nvm/init-nvm.sh' >> ~/.zshrc
Restart
nvm to install a Node.nvm install 12
Migrating
globally installednpm 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)