HOW to Install NPM on ubuntu 17.04

To Install NPM on ubuntu 17.04

Node.js is a platform built on Chrome’ s JavaScript runtime for easily building fast and scalable network applications.Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. Also, npm makes it easy for JavaScript developers to share and reuse code, and it makes it easy to update the code that you’ re sharing.
npm is written in Node.js, so you need to install Node.js in order to use npm and this tutorial covers the method to install NPM node.js on Ubuntu 17.04.

 

Installing NPM 

First,   make sure you update your package repository cache by making use of the following command

root@linuxhelp:~# apt-get update
Hit:1 http://old-releases.ubuntu.com/ubuntu zesty InRelease
Hit:2 http://ppa.launchpad.net/js-reynaud/kicad-4/ubuntu zesty InRelease
Hit:3 http://old-releases.ubuntu.com/ubuntu zesty-updates InRelease     
Hit:4 http://old-releases.ubuntu.com/ubuntu zesty-security InRelease
Reading package lists... Done


And then, you need to upgrade it as follows.    

root@linuxhelp:~# apt-get upgrade 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
.
.
Running hooks in /etc/ca-certificates/update.d...
done.
Processing triggers for systemd (232-21ubuntu7.1) ..


As mentioned earlier,   NPM is a Node.js package manager, so we need to install both for NPM to function. So you can install Node.js and NPM together with the following command.

root@linuxhelp:~# apt-get install nodejs npm
Reading package lists... Done
Building dependency tree       
Reading state information... Done
.
.
Setting up node-tar (2.2.1-1) ...
Setting up node-gyp (3.4.0-1) ...
Setting up npm (3.5.2-0ubuntu4) ...


Now run the following command to verify whether Node.js is working correctly.

root@linuxhelp:~# apt install nodejs-legacy
Reading package lists... Done
Building dependency tree       
Reading state information... Done
.
Processing triggers for man-db (2.7.6.1-2) ...

 

Update the NPM package repository cache with the following command.

root@linuxhelp:~# npm update

 

Also, search for a web framework, you would run the following command.

root@linuxhelp:~# npm search web framework
npm WARN notice update to the newest npm client for improved search results: npmjs.com/get-npm
| |----------------------------------------------------------------------------------------------------------|
NAME                    DESCRIPTION                                                  AUTHOR               DATE 
@sailshq/express        Sinatra inspired web development framework                   =sgress454 =irl&hellip      2017-
aframe                  A web framework for building virtual reality experiences.    =caseyyee =cvan&hellip      2017-
.
.
web-rax-framework       Rax framework for web.                                       =wintercn =yacheng&hellip   2017-

You can install a Node.js module globally or locally. The difference is that, global node modules can be accessed like any other commands, but it’ s not the case for locally installed modules. Soon you will see the difference.
Here we install “ express”  module locally to show you how to install Node.js module with NPM.

 

Also, make sure you create a directory for this Node.js project and navigate to the directory.

root@linuxhelp:~#mkdir node-demo & &  cd node-demo
root@linuxhelp:~/node-demo# 

 

And then, run the following command. 

root@linuxhelp:~/node-demo# npm install express
/home/user1/node-demo
`-- express@4.16.2 
  +-- accepts@1.3.4 
  | +-- mime-types@
.
.
npm WARN node-demo No README data
npm WARN node-demo No license field.

 

You can also install a module globally. Let’ s say you want to install ‘ express-generator’ globally, you would be running the following command.

root@linuxhelp:~/npm -g install express-generator
/usr/local/bin/express ->  /usr/local/lib/node_modules/express-generator/bin/express-cli.js
/usr/local/lib
`-- express-generator@4.15.5 
  +-- commander@2.11.0 
  +-- ejs@2.5.7 
  +-- mkdirp@0.5.1 
  | `-- minimist@0.0.8 
  `-- sorted-object@2.0.1

 

You can list locally installed Node.js modules with the following command. 

root@linuxhelp:~/node-demo# npm list 
/home/user1/node-demo
`-- express@4.16.2
  +-- accepts@1.3.4
  | +-- mime-types@2.1.17
  | | `-- mime-db@1.30.0
.
.
+-- type-is@1.6.15
  | `-- media-typer@0.3.0
  +-- utils-merge@1.0.1
  `-- vary@1.1.2

 

You can install globally installed Node.js Modules with the following command.

root@linuxhelp:~/node-demo# npm -g list
/usr/local/lib
`-- express-generator@4.15.5
  +-- commander@2.11.0
  +-- ejs@2.5.7
  +-- mkdirp@0.5.1
  | `-- minimist@0.0.8
  `-- sorted-object@2.0.1

With this, the tutorial Installing NPM on Ubuntu 17.04 comes to an end. 
 

Tag : Ubuntu npm
FAQ
Q
What is the command to install NPM on ubuntu 17.04?
A
The command to install NPM on ubuntu 17.04 is apt-get install nodejs npm
Q
What is nodejs and Npm?
A
Node.js is a platform built on Chrome&rsquo s JavaScript runtime for easily building fast and scalable network applications.Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices
Q
how can I setup two instance of node on windows?
A
please refer the following link, https://www.linuxhelp.com/how-to-install-multiple-instance-of-node-using-nvm-on-windows-7/
Q
how to install nodejs on ubuntu?
A
To install nodejs on ubuntu Please refer the link as follow "https://www.linuxhelp.com/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04/".
Q
How to install nodejs on centos?
A
To install nodejs on centos use the following link as "https://www.linuxhelp.com/how-to-install-node-js-in-centos/".