当前位置: 首页 > 知识库问答 >
问题:

npm-使用nodeJS的https代理错误

郑向阳
2023-03-14

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

npm WARN无效配置https代理="超文本传输协议:"npm WARN无效配置必须是一个完整的url'超文本传输协议://'

我尝试了很多事情:卸载/安装node和npm

  • 清理npm缓存
  • npm配置删除https代理
  • 将npm ssl设置为false
  • npm配置设置注册表http://registry.npmjs.org/
  • 试图覆盖它与npm配置设置https代理http://proxy.company.com:8080
  • 手动打开和更改npmrc全局和本地文件
  • 我在控制台registry.npmjs.orggoogle.es得到回应。

甚至我卸载了所有节点,并进行了新的编译,错误依然存在。

npm config get https proxy和npm config get http proxy

同时返回null。

my/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个答案

米楚青
2023-03-14

这是一个连接问题。

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

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

这使得npm客户端试图点击本地主机:8080来拉取模块,而不是正确的互联网endpoint。

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

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

那就跑

npm config edit

它在该文件中打开了一个文件,我删除了上面添加的三行,然后一切正常。

 类似资料:
  • 本文向大家介绍nodejs中request库使用HTTPS代理的方法,包括了nodejs中request库使用HTTPS代理的方法的使用技巧和注意事项,需要的朋友参考一下 正在尝试改用NodeJS编写爬虫,http请求库选择了 request ,用起来还是挺简单的。 现在有个需求,需要用Fiddler抓包我发出去的请求,以便和浏览器发出去的包进行对比。 因为需要解密HTTPS报文,需要让node要

  • 问题内容: 我正在安装某个NodeJS脚本-Caress。但我并非无法做到。我正在使用Windows 8.1,任何人都可以告诉我我面临的问题是什么,为什么该安装无法正常工作。据我所知,buffertools依赖性似乎存在问题。不知道该如何解决? 如果我从github下载构建并将其放置在节点模块中,则似乎没有任何效果。当我尝试启动时,使用npm start或在实现期间。 问题答案: 如下所述,您可能

  • 如何清除NPM以前的ssl代理设置?嗯,我搜索了很多,但我得到的所有帖子主要是关于如何在公司网络中代理。 第一个命令通过,而第二个命令警告: 是否可以忽略警告,并且我已成功清除代理设置?

  • 假设您想对某个网站执行https请求,但中间有一个代理。 上述代理不查看请求,只是在用户代理使用HTTP连接方法后将所有流量中继到实际的HTTPS服务器(如中所示http://www.web-cache.com/Writings/Internet-Drafts/draft-luotonen-web-proxy-tunneling-01.txt)。 现在我的问题是:在代理打开到目标Web服务器的SS

  • JVM 允许代理属性 http.代理主机和 http.代理端口用于指定 HTTP 代理服务器,以及 https.proxyHost 和 https.proxyPort 用于指定 HTTPS 代理服务器。 我想知道与HTTP代理服务器相比,使用HTTPS代理服务器是否有任何优势? 通过HTTPS代理访问https url是否比从HTTP代理访问它更麻烦?

  • 已安装最新的节点。Windows8上的js。如果我打字 在命令控制台中,我正确地看到 但是,每当我使用install命令时,不管参数是什么,都会出现以下错误 什么给?这可能是权限问题还是?