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.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

JPA Mini Book

Learn how to leverage the power of JPA in order to create robust and flexible Java applications. With this Mini Book, you will get introduced to JPA and smoothly transition to more advanced concepts.

JVM Troubleshooting Guide

The Java virtual machine is really the foundation of any Java EE platform. Learn how to master it with this advanced guide!

Given email address is already subscribed, thank you!
Oops. Something went wrong. Please try again later.
Please provide a valid email address.
Thank you, your sign-up request was successful! Please check your e-mail inbox.
Please complete the CAPTCHA.
Please fill in the required fields.

Leave a Reply


1 + six =



Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy | Contact
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.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below:
Close