NPM 未知协议 [英] NPM unknown protocol

查看:65
本文介绍了NPM 未知协议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行 npm install 时,出现以下错误.好像不能下载任何包.我使用节点 8.2.1 和 npm 5.3.0

When I run npm install I get following error. It seems it can't download any package. I use node 8.2.1 and npm 5.3.0

你知道出了什么问题吗?

Do you have any idea what is wrong?

npm ERR! code EPROTO
npm ERR! errno EPROTO
npm ERR! request to https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz failed,
reason: write EPROTO 140640770651968:error:140770FC:SSL 
routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:797:

npm 日志:

0215 verbose type system
20216 verbose stack FetchError: request to https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz failed, reason: write EPROTO 140640770651968:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:797:
20216 verbose stack
20216 verbose stack     at ClientRequest.req.on.err (/home/pawel/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/node-fetch-npm/src/index.js:68:14)
20216 verbose stack     at emitOne (events.js:115:13)
20216 verbose stack     at ClientRequest.emit (events.js:210:7)
20216 verbose stack     at onerror (/home/pawel/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/https-proxy-agent/node_modules/agent-base/index.js:106:9)
20216 verbose stack     at callbackError (/home/pawel/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/https-proxy-agent/node_modules/agent-base/index.js:126:5)
20216 verbose stack     at <anonymous>
20217 verbose cwd /home/pawel/work/react-components
20218 verbose Linux 4.4.0-83-generic
20219 verbose argv "/home/pawel/.nvm/versions/node/v8.2.1/bin/node" "/home/pawel/.nvm/versions/node/v8.2.1/bin/npm" "install"
20220 verbose node v8.2.1
20221 verbose npm  v5.3.0
20222 error code EPROTO
20223 error errno EPROTO
20224 error request to https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz failed, reason: write EPROTO 140640770651968:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:797:
20225 verbose exit [ 1, true ]

推荐答案

我也遇到了这个问题.以下技巧对我有用.

I also had this problem. The following trick has worked for me.

如果您将 nodenpm 版本升级到最新版本会更好.之后,请按照以下步骤操作.

It would be better if you upgrade your node and npm versions to latest. After that please follow the below steps.

尝试从终端运行 curl https://registry.npmjs.org/package-name 以确保网络调用不会阻止对 npm 的包请求注册表.

Try running curl https://registry.npmjs.org/package-name from your terminal to make sure that network call is not blocking the package requests to npm registry.

如果你在 proxy 后面运行,那么你还必须配置 npm 来使用它,你可以使用:

If you are running behind a proxy, then you also have to configure npm to use it, and you can set it using:

npm 配置设置代理 http://proxyhost:proxyport

npm config set http-proxy http://proxyhost:proxyport

npm config set https-proxy http://proxyhost:proxyport

npm 配置设置注册表 http://registry.npmjs.org/

希望以上技巧可以解决您的问题.

Hope the above trick resolve your issue.

这篇关于NPM 未知协议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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