How To Install Node.js on a CentOS 7 server

– 출처: https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-a-centos-7-server

Install Node Using the Node Version Manager

Another way of installing Node.js that is particularly flexible is through NVM, the Node version manager. This piece of software allows you to install and maintain many different independent versions of Node.js, and their associated Node packages, at the same time.

To install NVM on your CentOS 7 machine, visit the project’s GitHub page. Copy the curl or wgetcommand from the README file that displays on the main page. This will point you towards the most recent version of the installation script.

Before piping the command through to bash, it is always a good idea to audit the script to make sure it isn’t doing anything you don’t agree with. You can do that by removing the | bash segment at the end of the curl command:

curl https://raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh

Take a look and make sure you are comfortable with the changes it is making. When you are satisfied, run the command again with | bash appended at the end. The URL you use will change depending on the latest version of NVM, but as of right now, the script can be downloaded and executed by typing:

curl https://raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash

This will install the nvm script to your user account. To use it, you must first source your .bash_profile:

source ~/.bash_profile

Now, you can ask NVM which versions of Node it knows about:

nvm list-remote
. . .
v0.10.29
v0.10.30
 v0.11.0
 v0.11.1
 v0.11.2
 v0.11.3
 v0.11.4
 v0.11.5
 v0.11.6
 v0.11.7
 v0.11.8
 v0.11.9
v0.11.10
v0.11.11
v0.11.12
v0.11.13

You can install a version of Node by typing any of the releases you see. For instance, to get version 0.10.30, you can type:

nvm install v0.10.30

You can see the different versions you have installed by typing:

nvm list
->  v0.10.30
      system

You can switch between them by typing:

nvm use v0.10.30
Now using node v0.10.30

To set this version as the default, type:

nvm alias default v0.10.30
default -> v0.10.30

You can verify that the install was successful using the same technique from the other sections, by typing:

node --version
v0.10.30

From the version number output, we can tell that Node is installed on our machine as we expected.

댓글 남기기