首页 文章

npm - 使用nodeJS的https代理错误

提问于
浏览
0

这是错误,不会让我什么都不安装:

npm WARN无效配置https-proxy =“http:”npm WARN无效配置必须是带有'http://'的完整网址

我尝试了很多东西:卸载/安装节点和npm

  • 清理npm缓存

  • npm config删除https-proxy

  • 将npm ssl设置为false

  • npm config set registry http://registry.npmjs.org/

  • 试图用npm配置设置覆盖它https-proxy http://proxy.company.com:8080

  • 打开并手动更改npmrc全局和本地文件

  • 我得到了对控制台中的registry.npmjs.org和google.es进行ping操作的响应 .

即使我卸载所有节点并进行新的编译并且错误仍然存在 .

npm config获取https-proxy,npm config获取http-proxy

两个都返回null .

我的/home/usertv/npm-debug.log

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'install',
1 verbose cli   '-g',
1 verbose cli   'cordova' ]
2 info using npm@1.3.21
3 info using node@v0.10.24
4 warn invalid config https-proxy="http:"
5 warn invalid config Must be a full url with 'http://'
6 verbose cache add [ 'cordova', null ]
7 verbose cache add name=undefined spec="cordova" args=["cordova",null]
8 verbose parsed url { protocol: null,
8 verbose parsed url   slashes: null,
8 verbose parsed url   auth: null,
8 verbose parsed url   host: null,
8 verbose parsed url   port: null,
8 verbose parsed url   hostname: null,
8 verbose parsed url   hash: null,
8 verbose parsed url   search: null,
8 verbose parsed url   query: null,
8 verbose parsed url   pathname: 'cordova',
8 verbose parsed url   path: 'cordova',
8 verbose parsed url   href: 'cordova' }
9 silly lockFile a98f2055-cordova cordova
10 verbose lock cordova /root/.npm/a98f2055-cordova.lock
11 silly lockFile a98f2055-cordova cordova
12 silly lockFile a98f2055-cordova cordova
13 verbose addNamed [ 'cordova', '' ]
14 verbose addNamed [ null, '*' ]
15 silly lockFile de8d9fad-cordova cordova@
16 verbose lock cordova@ /root/.npm/de8d9fad-cordova.lock
17 silly addNameRange { name: 'cordova', range: '*', hasData: false }
18 verbose url raw cordova
19 verbose url resolving [ 'http://registry.npmjs.org/', './cordova' ]
20 verbose url resolved http://registry.npmjs.org/cordova
21 info trying registry request attempt 1 at 12:25:02
22 http GET http://registry.npmjs.org/cordova
23 info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND
24 info trying registry request attempt 2 at 12:25:13
25 http GET http://registry.npmjs.org/cordova
26 info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND
27 info trying registry request attempt 3 at 12:26:13
28 http GET http://registry.npmjs.org/cordova
29 silly lockFile de8d9fad-cordova cordova@
30 silly lockFile de8d9fad-cordova cordova@
31 error network getaddrinfo ENOTFOUND
31 error network This is most likely not a problem with npm itself
31 error network and is related to network connectivity.
31 error network In most cases you are behind a proxy or have bad network settings.
31 error network
31 error network If you are behind a proxy, please make sure that the
31 error network 'proxy' config is set properly.  See: 'npm help config'
32 error System Linux 3.2.0-4-686-pae
33 error command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "cordova"
34 error cwd /home/usertv
35 error node -v v0.10.24
36 error npm -v 1.3.21
37 error syscall getaddrinfo
38 error code ENOTFOUND
39 error errno ENOTFOUND
40 verbose exit [ 1, true ]

我的npm配置ls -l

; cli configs
long = true
registry = "http://registry.npmjs.org/"

; userconfig /home/usertv/.npmrc
registry = "http://registry.npmjs.org/"
strict-ssl = false

; globalconfig /usr/local/etc/npmrc
registry = "http://registry.npmjs.org/"

; default values
always-auth = false
bin-links = true
browser = null
cache = "/home/usertv/.npm"
cache-lock-retries = 10
cache-lock-stale = 60000
cache-lock-wait = 10000
cache-max = null
cache-min = 10
cert = null
color = true
depth = null
description = true
dev = false
editor = "vi"
email = null
engine-strict = false
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
force = false
git = "git"
git-tag-version = true
global = false
globalconfig = "/usr/local/etc/npmrc"
globalignorefile = "/usr/local/etc/npmignore"
group = 1000
heading = "npm"
https-proxy = null
ignore-scripts = false
init-module = "/home/usertv/.npm-init.js"
init.author.email = ""
init.author.name = ""
init.author.url = ""
init.license = "ISC"
json = false
key = null
link = false
local-address = undefined
loglevel = "http"
; long = false (overridden)
message = "%s"
node-version = "v0.10.24"
npat = false
onload-script = false
optional = true
parseable = false
prefix = "/usr/local"
production = false
proprietary-attribs = true
proxy = null
rebuild-bundle = true
; registry = "https://registry.npmjs.org/" (overridden)
rollback = true
save = false
save-bundle = false
save-dev = false
save-optional = false
searchexclude = null
searchopts = ""
searchsort = "name"
shell = "/bin/bash"
shrinkwrap = true
sign-git-tag = false
; strict-ssl = true (overridden)
tag = "latest"
tmp = "/home/usertv/tmp"
umask = 18
unicode = true
unsafe-perm = true
usage = false
user = 0
user-agent = "node/v0.10.24 linux ia32"
userconfig = "/home/usertv/.npmrc"
username = ""
version = false
versions = false
viewer = "man"

1 回答

  • 1

    这是一个连接问题 .

    我记得我错误地使用了代理配置,如下所示:

    npm config set proxy http://localhost:8080/
       npm config set https-proxy http://localhost:8080/
       npm config set strict-ssl false
    

    这使得npm客户端尝试命中localhost:8080来拉取模块而不是正确的Internet endpoints .

    经过几天的挫折后,我访问了这个链接

    https://docs.npmjs.com/cli/config

    然后运行

    npm config edit
    

    打开文件里面的文件,我删除了上面添加的那三行,然后一切正常 .

相关问题