Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nodejs npm global config missing on windows

I can't find at all where npm has its global settings stored.

npm config get userconfig

C:\Users\Jack\.npmrc 

npm config get globalconfig

C:\Users\Jack\AppData\Roaming\npm\etc\npmrc 

There's no files at either of these paths and yet

npm config get proxy -> returns my proxy url for work. which I want to delete.

npm config -g delete proxy

npm ERR! Error: ENOENT, unlink 'C:\Users\Jack\AppData\Roaming\npm\etc\npmrc'  npm ERR! System Windows_NT 6.2.9200 npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "config" "-g" "delete" "proxy" npm ERR! cwd C:\f\Dropbox\apps npm ERR! node -v v0.8.22 npm ERR! npm -v 1.2.14 npm ERR! path C:\Users\Jack\AppData\Roaming\npm\etc\npmrc npm ERR! code ENOENT npm ERR! errno 34 npm ERR! npm ERR! Additional logging details can be found in: npm ERR!     C:\f\Dropbox\apps\npm-debug.log npm ERR! not ok code 0 
like image 369
Jack Avatar asked Mar 20 '13 23:03

Jack


People also ask

Where is global npm config?

Global config file: $PREFIX/npmrc. Built-in npm config file: /path/to/npm/npmrc.

Where is the npm config file on Windows?

The prefix config defaults to the location where node is installed. On most systems, this is /usr/local . On Windows, it's %AppData%\npm .

How do I get npm config?

Run npm config ls -l to see a set of configuration parameters that are internal to npm, and are defaults if nothing else is specified.


1 Answers

There is a problem with upgrading npm under Windows. The inital install done as part of the nodejs install using an msi package will create an npmrc file:

C:\Program Files\nodejs\node_modules\npm\npmrc

when you update npm using:

npm install -g npm@latest

it will install the new version in:

C:\Users\Jack\AppData\Roaming\npm

assuming that your name is Jack, which is %APPDATA%\npm.

The new install does not include an npmrc file and without it the global root directory will be based on where node was run from, hence it is C:\Program Files\nodejs\node_modules

You can check this by running:

npm root -g

This will not work as npm does not have permission to write into the "Program Files" directory. You need to copy the npmrc file from the original install into the new install. By default the file only has the line below:

prefix=${APPDATA}\npm

like image 74
oenpelli Avatar answered Sep 22 '22 17:09

oenpelli