Ubuntu NodeJs 安装

Summary: Author: 张亚飞 | 阅读时间: 2 minute read | Published: 2016-06-11
Filed under Categories: LinuxTags: Note,

Ubuntu 安装 NodeJs


源码编译安装

sudo wget https://github.com/nodejs/node/archive/v6.3.1.tar.gz
sudo tar zxvf v6.3.1.tar.gz
cd node-4.4.5
./configure
make
make install
node -v
v6.3.1

参考


  • [Mac/Linux] 使用 nvm 安装 node.js

First, make sure you have a C++ compiler. Open the terminal and install the build-essential and libssl-dev packages if needed. By default, Ubuntu does not come with these tools — but they can be installed in the command line.

Use apt to install the build-essential package:

sudo apt install build-essential checkinstall

Employ a similar process to get libssl-dev:

sudo apt install libssl-dev

You can install and update Node Version Manager, or nvm, by using cURL:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

You will be asked to close and reopen the terminal. To verify that nvm has been successfully installed after you reopen the terminal, use:

command -v nvm

That command will output nvm if the installation worked.

To download, compile and install the latest version of Node:

nvm install 5.0

In any new shell, you’ll need to tell nvm which version to use:

nvm use 5.0
  • 设置默认 Node 版本…
nvm alias default 9.3.0

Fresh installation

Use the NodeSource PPA. For details look at the installation instructions. First, choose the Node.js version you need and add the sources for it:

for Node.js v4

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -

OR for Node.js v5

curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -

OR for Node.js v6

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -

Then install the Node.js package.

sudo apt install -y nodejs

P.S.: curl package must be installed on server for these code lines.

Upgrading

If you have nodejs already installed and want to update, then first remove current instalation and install it again using scripts above.

sudo apt purge nodejs npm

参考

Comments

Cor-Ethan, the beverage → www.iirii.com