bar
8/23/2018 - 8:27 AM

node js npm install ubuntu 18

node js npm install ubuntu 18

https://linuxconfig.org/how-to-install-node-js-on-ubuntu-18-04-bionic-beaver-linux




How to Install Node.js on Ubuntu 18.04 Bionic Beaver Linux
Lubos Rendek Ubuntu 18.04 30 May 2018
Contents
1. Objective
2. Operating System and Software Versions
3. Requirements
4. Difficulty
5. Conventions
6. Instructions
6.1. Install Node.js using Standard Ubuntu 18.04 Repository
6.2. Install Node.js using NodeSource
6.3. Install Node.js using Node Version Manager (NVM)
6.4. Basic guide to NVM
6.4.1. Switch Node.js Version
6.4.2. List all Node.js Installed versions
6.4.3. Set default Node.js Version
6.4.4. Remove Node.js
Objective
The objective is to install Node.js the cross-platform JavaScript runtime environment on Ubuntu 18.04 Bionic Beaver Linux from standard Ubuntu 18.04 repository or by use of Node Version Manager, NVM.

This tutorial is available for other Ubuntu Versions:
Operating System and Software Versions
Operating System: - Ubuntu 18.04 Bionic Beaver
Requirements
Privileged access to your Ubuntu System as root or via sudo command is required.
Difficulty
EASY
Conventions
# - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user
Instructions
Install Node.js using Standard Ubuntu 18.04 Repository
Perhaps the fastest and easiest way to install Node.js on Ubuntu 18.04 is to perform an installation from a standard Ubuntu 18.04 repository. This will also ensure that you end up with a most stable and tested Node.js version at the cost of slightly lower version number. The following linux command:
$ sudo apt install nodejs
Additionally, you may want to also install Node.js package manager npm:
$ sudo apt install npm
Confirm installed versions:
$ nodejs --version
v6.12.0
$ npm --version
3.5.2
To remove Node.js execute:
$ sudo apt purge nodejs
Install Node.js using NodeSource
NodeSource is a former PPA repository for Node.js. To install Node.js version 8 execute:
$ url -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
$ sudo apt-get install -y nodejs
For Node.js version 10 run:
$ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
$ sudo apt-get install -y nodejs
Test the Node.js version:
$ nodejs --version
v10.7.0
Install Node.js using Node Version Manager (NVM)
Using NVM is most flexible and recommended way to install Node.js if the Node.js version installed from the above standard Ubuntu 18.04 repository does not fit your needs. NVM allows you to install any Node.js version as well as switch between Node.js versions in a very simple manner. Let's begin by installation of Node Version Manager. Update the version number if necessary:
$ wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
To update your shell environment with new NVM settings either close and re-open your terminal session or enter:
$ source ~/.profile
NVM should now be available:
$ nvm --version
0.33.8
As already mentioned, nvm allows for an install of any available Node.js version. The following linux command will list all Node.js versions available:
$ nvm ls-remote
For example, to find the latest long term support version you may run:
$ nvm ls-remote | grep -i "latest lts"
         v4.8.7   (Latest LTS: Argon)
        v6.12.3   (Latest LTS: Boron)
         v8.9.4   (Latest LTS: Carbon)
Once you have chosen the Node.js version eg. v8.9.4 you may install it using the following linux command:
$ nvm install 8.9.4
All done. Check versions:
$ node --version
v8.9.4
$ npm --version
5.6.0