Install nodejs using NVM
Install nodejs using NVM
Here is the official github repo of NVM: https://github.com/nvm-sh/nvm
Follow the document, you can use code below to install NVMcurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
You probably need to reopen the terminal to make nvm working.
Check nvm versionnvm --version
Get installed node versionnvm ls
Get node version from servernvm ls-remote
Get LTS node version from servernvm ls-remote | grep LTS
Install nodenvm install v18.16.1 nvm install 18
Note: to support higher version node, you may need to upgrade you linux server, CentOS7 currently only support node version < 18nvm install v16.20.1 nvm install 16
To uninstall nodenvm uninstall 18
To switch node versionnvm use v16.20.1 nvm use 16
To find out where nvm manage all node versionswhich node or whereis node
You will see something like this, path:/root/.nvm/versions/node/v16.20.1/bin/node