nodejs 安装
1、使用
#debian ubuntu curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash - sudo apt-get install -y nodejs #centos curl --silent --location https://rpm.nodesource.com/setup_7.x | bash -
2、源码安装
git clone git://github.com/ry/node.git cd node ./configure make sudo make install
3、nvm 安装
curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash 或 wget -qO- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash #加入这三行 到 .bashrc 或 .bash_profile 文件 export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion #安装node nvm ls-remote
nvm install node #安装node最新版 nvm install v7.9.0 nvm use v7.9.0
nvm alias default node
遇到错误解决方法:
安装最新版nvm后发现 nvm ls-remote 只能找到iojs的版本,貌似是ssl证书问题,解决方法是在.bashrc 或 .profile文件添加
export NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist 或 export NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/dist
参考资料:
1、 https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-an-ubuntu-14-04-server
2、 https://fengmk2.com/blog/2014/03/node-env-and-faster-npm.html 快速搭建 Node.js / io.js 开发环境以及加速 npm
3、 https://nodejs.org/en/download/package-manager/
4、 http://www.jianshu.com/p/20b57333617a fedora 23下使用nvm ls-remote只显示iojs
5、 https://github.com/nodesource/distributions