a blog for those who code

Thursday, 6 October 2016

Change the User Level Configuration when installing Nodejs Packages

This is a beginner post of Node.js where we will show you how to change the user level configuration when you install Nodejs packages using npm install. One of the sources of npm configuration is npmrc file which can be per-project, per-user, global config file etc.


ALSO READ : Pass command line arguments in NodeJS

Now in this post we will show you how to change the default configuration file for all the packages to be installed in your current project.

Usually to install modules mentioned on package.json we use the command "npm install". This command acts the same ways as installing on the command-line. The version of the packages will be depends of what is specified in package.json, if nothing is defined it will install the latest version.

But sometimes you want to change the config settings from the command line, thus you can specify which configuration file to pick when you will be installing the packages. This can be done using the userconfig command line flags as shown below :

npm --userconfig=./.npmrcnew install

Which will install the modules as mentioned in package.json while considering the configuration file supplied by the --userconfig argument. You can either write i or install to install the packages.

ALSO READ : Get Call Stack Information in NodeJS


Please Like and Share the CodingDefined Blog, if you find it interesting and helpful.

No comments:

Post a Comment

Contact Us

Name

Email *

Message *

Sponsers

Best Hosting Plans

CC License