Windows 上缺少 nodejs npm 全局配置 [英] nodejs npm global config missing on windows

查看:80
本文介绍了Windows 上缺少 nodejs npm 全局配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我根本找不到 npm 存储全局设置的位置.

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

npm 配置获取用户配置

npm config get userconfig

C:\Users\Jack\.npmrc

npm 配置获取全局配置

npm config get globalconfig

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

这些路径中的任何一个都没有文件,但

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

npm 配置获取代理-> 返回我的工作代理网址.我想删除.

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

npm config -g 删除代理

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

推荐答案

看起来 npm 用于编辑其配置文件的文件不是在全新安装时创建的,如 npm 每个都有一个默认选项.这就是为什么你仍然可以使用 npm config get 获取选项的原因:让这些文件只覆盖默认值,它不会从头开始创建选项.

It looks like the files npm uses to edit its config files are not created on a clean install, as npm has a default option for each one. This is why you can still get options with npm config get <option>: having those files only overrides the defaults, it doesn't create the options from scratch.

在今天之前,我从未接触过我的 npm config 东西,尽管我已经拥有它几个月了.还没有任何文件,例如 ~/.npmrc(在带有 Git Bash 的 Windows 8.1 机器上),但我可以运行 npm config get <something> 并且,如果它是一个正确的 npm 选项,它会返回一个值.当我运行 npm config set ,文件 ~/.npmrc 似乎是自动创建的,带有选项 &其值是唯一未注释掉的行.

I had never touched my npm config stuff before today, even though I had had it for months now. None of the files were there yet, such as ~/.npmrc (on a Windows 8.1 machine with Git Bash), yet I could run npm config get <something> and, if it was a correct npm option, it returned a value. When I ran npm config set <option> <value>, the file ~/.npmrc seemed to be created automatically, with the option & its value as the only non-commented-out line.

至于删除选项,看起来这只是将值设置回默认值,或者如果该选项从未设置或未设置,则什么也不做&永不重置.此外,如果该选项是唯一显式设置的选项,则 ~/.npmrc 看起来也被删除了,如果您稍后设置 其他任何内容,则会重新创建.

As for deleting options, it looks like this just sets the value back to the default value, or does nothing if that option was never set or was unset & never reset. Additionally, if that option is the only explicitly set option, it looks like ~/.npmrc is deleted, too, and recreated if you set anything else later.

在您的情况下(假设它在一年后仍然相同),您似乎从未在 npm 中设置 proxy 选项.因此,正如 npmconfig 帮助页面所说,它被设置为您的 http_proxy(不区分大小写)环境变量.这意味着没有什么可delete,除非您想删除"您的HTTP 代理,尽管您可以set 将选项或环境变量设置为其他内容,并希望不会破坏您的以某种方式设置.

In your case (assuming it is still the same over a year later), it looks like you never set the proxy option in npm. Therefore, as npm's config help page says, it is set to whatever your http_proxy (case-insensitive) environment variable is. This means there is nothing to delete, unless you want to "delete" your HTTP proxy, although you could set the option or environment variable to something else and hope neither breaks your set-up somehow.

这篇关于Windows 上缺少 nodejs npm 全局配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆