I might have covered the Node.js and NPM installation back in my first post regarding the installation of node.js but this post will give you a thorough explanation regarding npm and some issues you might encounter.
In case you have the same issue, i mean
npm : command not found‘
here is what you need to do
- curl -k -O -L https://npmjs.org/install.sh
- sh install.sh
Check (paths) in your Terminal typing
which node: should return
which npm: should return
If the problem remains please use the comments below and let me know the problem.
Moving on Node Package Manager (NPM) provides two main functionalities
- Online repositories for node.js packages/modules which are searchable on search.nodejs.org
- Command line utility to install Node.js packages, do version management and dependency management of Node.js packages.
Installing Modules using NPM
There are many packages for Node such as the popular grunt.js, you use the command npm to see a complete list run:
$ npm search
There is a simple syntax to install any Node.js module −
$ npm install <Module Name>
For example, following is the command to install a famous Node.js web framework module called express −
$ npm install express
Now you can use this module in your js file as following −
var express = require('express');
Uninstalling a Module
Use the following command to uninstall a Node.js module.
$ npm uninstall express
Once NPM uninstalls the package, you can verify it by looking at the content of /node_modules/ directory or type the following command −
$ npm ls
To upgrade npm packages
[alert type=white ]
Previous Node.js Posts
Part 2 – Node.JS-Intro