About Piyas De

Piyas is Sun Microsystems certified Enterprise Architect with 10+ years of professional IT experience in various areas such as Architecture Definition, Define Enterprise Application, Client-server/e-business solutions.

Node.js Package Manager

Node.js standard packages and modules are installed through standard packaging application – called as Node Package Manager(NPM). NPM is the standard for packaging the node.js components and modules. In the packages, the “package.json” is included to write the dependencies in Node.js and the startig file in node package.

There are two ways of installing node packages – Local and Global.

For Global Packages, the node packages will be loaded and installed in shared folders and those can be used in several node.js applications which are developed in different workspaces. In shared folder one version of node.js packge will be installed.

In local mode, node.js keeps same node packages in different application folders within a directory called – ‘node_modules’ where the different local node modules will be installed. NPM works with local mode by default and to work with global mode, the NPM command should be installed with “-g” option.

Some important NPM commands we have put here below -

A> npm ls -it will show all the packages and versions and show those in terminal console.

B> A variation of “npm ls” is to tag with options- like (list all installed packages) -

  1. npm ls installed
  2. npm ls stable – to show all the node packages and modules which are declared as stable.
  3. npm ls installed stable – to combine the above filters

C> Search for the installed packages with a particular string within.

npm ls sample

Here npm will search and show packages and modules with “sample” word contained.

D> To get query with version numbers -

npm ls @2.0

E> To install latest version of a node package -

npm install package_name

Example - npm install validation

It will install the node validation module within local node module repository from the Internet.

F> To install specific version of package -

npm install package@version

This will be specially required in case of any particular function invocation, which may not be present in the node present stable version.

G> To install some module within global context the command will be -

npm install -g package_name

Example - npm install -g express

It will install the express.js package with node.js global node in local development environment.

H> To remove a perticular package

npm rm package_name

– it will delete all the specific packages installed from node.js repository. To remove file from Global repository,

we need to use “-g” switch.

Example – npm rm -g validation

I> To veiw information for some package, we need to use

npm view validation

J> To view information for some specific versioned package -

npm view [email protected]

That is all for now. We will write more on other node.js features in our later articles.

Reference: Node.js Package Manager from our JCG partner Piyas De at the Phlox Blog blog.
Related Whitepaper:

Software Architecture

This guide will introduce you to the world of Software Architecture!

This 162 page guide will cover topics within the field of software architecture including: software architecture as a solution balancing the concerns of different stakeholders, quality assurance, methods to describe and evaluate architectures, the influence of architecture on reuse, and the life cycle of a system and its architecture. This guide concludes with a comparison between the professions of software architect and software engineer.

Get it Now!  

Leave a Reply

9 − = two

Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.

Sign up for our Newsletter

20,709 insiders are already enjoying weekly updates and complimentary whitepapers! Join them now to gain exclusive access to the latest news in the Java world, as well as insights about Android, Scala, Groovy and other related technologies.

As an extra bonus, by joining you will get our brand new e-books, published by Java Code Geeks and their JCG partners for your reading pleasure! Enter your info and stay on top of things,

  • Fresh trends
  • Cases and examples
  • Research and insights
  • Two complimentary e-books