cannot locate .npmrc file after installing nodejs and npm on ubuntu 12.04

v09 picture v09 · Jun 29, 2013 · Viewed 56.3k times · Source

I just followed a tutorial to install nodejs and npm on my ubuntu 12.04. https://gist.github.com/dwayne/2983873

now after installing both are working fine. I checked them by

node -v npm -v

They seem to give me desired result. My question is I am not able to locate .npmrc file. Is n't it weird.

I want to know is it created by default when we install npm ? or should I create it myself.?

Answer

user568109 picture user568109 · Jul 5, 2013

There can be per-user, global and built-in npmrc configs. So don't worry about if there is no .npmrc file in your home directory. userconfig may or may not exist. You can check the documentation on npm configuration files.

userconfig is not created for all users. To check if user config is there and its location you can do :

npm config ls -l | grep config

My output comes out as

; cli configs
; userconfig /home/ubuntu/.npmrc
globalconfig = "/data/storage/node-v0.8.8-linux-x64/etc/npmrc"
userconfig = "/home/ubuntu/.npmrc"

The global npmrc exists where the npm is installed. And user's has its own. The userconfig file has higher priority over global config, when searching for keys. But if it is absent globalconfig is used.