Installing Node.js and NPM on Ubuntu/Debian
一、包管理器安装
安装nodejs 6,这是目前大多是nodejs应用运行的依赖版本:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -sudo apt-get install -y nodejs
如果安装 Node.js v7:
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -sudo apt-get install -y nodejs
更多操作系统的nodejs安装方法:
二、通过源码安装
24 October 2011
This is just short snippet on how to install Node.js (any version) and NPM (Node Package Manager) on your Ubuntu/Debian system.
Step 1 - Update your system
sudo apt-get updatesudo apt-get install git-core curl build-essential openssl libssl-dev
Step 2 - Install Node.js
First, clone the Node.js repository:
git clone https://github.com/joyent/node.gitcd node
Now, if you require a specific version of Node:
git tag # Gives you a list of released versionsgit checkout v0.4.12
Then compile and install Node like this:
./configuremakesudo make install
Then, check if node was installed correctly:
node -v
Step 3 - Install NPM
Simply run the NPM install script:
curl -L https://npmjs.org/install.sh | sudo sh
And then check it works:
npm -v
That’s all.