linux下安装nodejs

来源:互联网 发布:淘宝折800 编辑:程序博客网 时间:2024/05/17 04:39

推荐方法:

// 下载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.shsource ~/.profile // 设置默认运行的node版本$ nvm alias default 0.12// 验证 nvm ls 如果出现了default为7.4.0 表现安装成功,之后任意打开都可以实现node的使      用 default -> 7.4.0 (-> v7.4.0)

其他方法:
1.编译包解压+配置变量

wget https://npm.taobao.org/mirrors/node/latest-v4.x/node-v4.4.7-linux-x64.tar.gztar -zxvf node-v4.4.7-linux-x64.tar.gzexport PATH=$PATH:/opt/node-v4.4.7-linux-x64/bin

2.源码包编译+安装+配置变量

3.apt-get安装