Install nodejs and remove nodejs

安装

方法一:

Ubuntu 系统

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs

Debian 系统。以 root 权限执行下列指令

curl -sL https://deb.nodesource.com/setup_4.x | bash -
apt-get install -y nodejs

http://www.ghostchina.com/install-nodejs-of-latest-version-in-ubuntu-and-debian/

方法二:

Setup with Ubuntu:

curl -sL https://deb.nodesource.com/setup | sudo bash -

Then install with Ubuntu:

sudo apt-get install -y nodejs

注:此方法只能安装node最低版本

方法三:

使用如下方法,可安装指定版本的nodejs:

  • On the app server, let’s update the apt-get package lists with this command:
$ sudo apt-get update
  • Then use apt-get to install the git package, which npm depends on
$ sudo apt-get install git
  • Change to your home directory and download the Node.js source with wget. Paste the download link in place of the highlighted part:
$ cd ~
$ wget https://nodejs.org/dist/v4.2.3/node-v4.2.3-linux-x64.tar.gz
  • Now extract the tar archive you just downloaded into the node directory with these commands:
$ mkdir node
$ tar xvf node-v*.tar.?z --strip-components=1 -C ./node
$ cd ~
$ rm -rf node-v*
  • Next, we’ll configure the global prefix of npm, where npm will create symbolic links to installed Node packages, to somewhere that it’s in your default path. We’ll set it to /usr/local with this command:
$ mkdir node/etc
$ echo 'prefix=/usr/local' > node/etc/npmrc
  • Now we’re ready to move the node and npm binaries to our installation location. We’ll move it into /opt/node with this command:
$ sudo mv node /opt/
  • At this point, you may want to make root the owner of the files:
$ sudo chown -R root: /opt/node
  • Lastly, let’s create symbolic links of the node and npm binaries in your default path. We’ll put the links in /usr/local/bin with these commands:
$ sudo ln -s /opt/node/bin/node /usr/local/bin/node
$ sudo ln -s /opt/node/bin/npm /usr/local/bin/npm
  • Verify that Node is installed by checking its version with this command:
$ node -v

注:以上内容转发自—————->
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-14-04

Setup with Debian (as root):

apt-get install curl
curl -sL https://deb.nodesource.com/setup | bash -

Then install with Debian (as root):

apt-get install -y nodejs

卸载

$ sudo apt-get remove nodejs
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值