A blog for technology, SEO tips, website development and open source programming.

Node.js and NPM

0 927

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

Check (paths) in your Terminal typing

  • which node : should return /usr/local/bin/node
  • which npm : should return /usr/local/bin/npm

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

npm update

[alert type=white ]
Previous Node.js Posts

Part 1 – Installing node.js on OSX – macOS Sierra

Part 2 – Node.JS-Intro

Part 3 – Node.js and NPM

Follow me on Instagram


Leave a Reply

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More