How to install Node.js via binary archive on Linux?

1. Node.js Download

2. Unzip the binary archive to any directory you wanna install Node, I use /usr/local/lib/nodejs

$ NODE_VERSION=v10.15.0
$ NODE_DISTRO=linux-x64
$ sudo mkdir -p /usr/local/lib/nodejs
$ sudo tar -xJvf node-$NODE_VERSION-$NODE_DISTRO.tar.xz -C /usr/local/lib/nodejs 

3. Set the environment variable ~/.profile OR ~/.bash_profile , add below to the end

$ vi ~/.profile or
# or 
$ vi ~/.bash_profile
# .profile or .bash_profile add below to the end
# Nodejs
NODE_VERSION=v10.15.0
NODE_DISTRO=linux-x64
export PATH=/usr/local/lib/nodejs/node-$NODE_VERSION-$NODE_DISTRO/bin:$PATH

4. Refresh profile

$ source ~/.profile
# or
$ source ~/.bash_profile

5. Test installation using

$ node -v
$ npm version
$ npx -v

6. Change npm global path

# 1. Make a directory for global installations
$ mkdir ~/.npm-global
# 2. Configure npm to use the new directory path
$ npm config set prefix '~/.npm-global'
# 3. Open or create a ~/.profile file and add this line
$ vi ~/.profile 
or 
$ vi ~/.bash_profile
# 4. add below to the end
export PATH=~/.npm-global/bin:$PATH
# 5. Back on the command line, update your system variables
$ source ~/.profile
# or
$ source ~/.bash_profile
# 6. test
$ npm install -g jshint

https://github.com/nodejs/help/wiki/Installation

http://npm.github.io/installation-setup-docs/installing/a-note-on-permissions.html

댓글 남기기