- 参考
下载
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
激活
- Activate NVM: Once the installation script completes, you need to either close and reopen the terminal or run the following command to use nvm immediately.
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Step 2: Installing Node.js using NVM
After installing NVM, you can install Node.js. NVM makes it easy to install any version of Node.js. To install the latest version, use:
- 最新版本:
nvm install node
- 安装指定版本:
To install a specific version of Node.js, you can do so by specifying the version number, for example:
直接use不行,得先install 才能use
root@k8s-master-pfsrv:/home/zhangbin/perfwork/01_ai/01_semantic-text2image-search/frontend# nvm install 21.5.0
Downloading and installing node v21.5.0...
Downloading https://nodejs.org/dist/v21.5.0/node-v21.5.0-linux-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v21.5.0 (npm v10.2.4)
Creating default alias: default -> 21.5.0 (-> v21.5.0)
root@k8s-master-pfsr
Step 4: Setting a Default Node.js Version
- To avoid having to manually switch versions every time you open a new terminal, you can set a default Node.js version with NVM:
nvm alias default <version_number>