安装 nvm
执行如下命令
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
查询服务器所有可用版本
nvm ls-remote
安装8.11.1
版本
nvm install 8.11.1
使用 node
- 使用已安装的最新版:
nvm use node
- 使用指定版本:
nvm use 8.11.1
常见问题
报错信息如下:
=> You currently have modules installed globally with
npm
. These will no
=> longer be linked to the active version of Node when you install a new node
=> withnvm
; and they may (depending on how you construct your$PATH
)
=> override the binaries of modules installed withnvm
:解决办法:
- yum remove -y nodejs
- 重新与服务器建立连接
- nvm –version