Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
701 views
in Technique[技术] by (71.8m points)

node.js - 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:UsersJack.npmrc

npm config get globalconfig

C:UsersJackAppDataRoaming
pmetc
pmrc

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:UsersJackAppDataRoaming
pmetc
pmrc'

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:fDropboxapps
npm ERR! node -v v0.8.22
npm ERR! npm -v 1.2.14
npm ERR! path C:UsersJackAppDataRoaming
pmetc
pmrc
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:fDropboxapps
pm-debug.log
npm ERR! not ok code 0
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 odejs ode_modules pm pmrc

when you update npm using:

npm install -g npm@latest

it will install the new version in:

C:UsersJackAppDataRoaming pm

assuming that your name is Jack, which is %APPDATA% pm.

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 odejs ode_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} pm


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...