在CentOS中配置Node.js,可参考以下步骤:
sudo yum update -y
。curl -sL https://rpm.nodesource.com/setup_16.x | sudo bash -
,再安装sudo yum install -y nodejs
;使用NVM时,先安装NVMcurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
,然后加载NVMsource ~/.bashrc
,再安装指定版本,如nvm install 16
。node -v
和npm -v
命令查看版本,确认安装成功。~/.bashrc
或/etc/profile
文件,在文件末尾添加export PATH=$PATH:/usr/bin/node:/usr/bin/npm
,保存后运行source ~/.bashrc
或source /etc/profile
使更改生效。