推荐方法:
?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | // 下载nvm $ git clone https: //github .com /cnpm/nvm .git // 安装你需要的版本,然后你就可以在任何目录下使用node以及npm了 $ nvm install 7.4.0 // 新打开的窗口,如果无法实现,那么还需要下面两步 // 1 配置终端启动时自动执行,在 ~/.bashrc, ~/.bash_profile, ~/.profile, 或者 ~/.zshrc 文件添加以下命令:(.profile中修改亲测有效) source ~ /git/nvm/nvm .sh source ~/.profile // 设置默认运行的node版本 $ nvm alias default 0.12 // 验证 nvm ls 如果出现了default为7.4.0 表现安装成功,之后任意打开都可以实现node的使 用 default -> 7.4.0 (-> v7.4.0) |
其他方法:
1.编译包解压+配置变量
?
| 1 2 3 | wget https: //npm .taobao.org /mirrors/node/latest-v4 .x /node-v4 .4.7-linux-x64. tar .gz tar -zxvf node-v4.4.7-linux-x64. tar .gz export PATH=$PATH: /opt/node-v4 .4.7-linux-x64 /bin |
2.源码包编译+安装+配置变量
3.apt-get安装
搬瓦工中文网





