安装
方法一:
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