Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

node.js - NPM unknown protocol

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 logs:

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 ]
See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

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

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

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.

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

npm config set proxy http://proxyhost:proxyport

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

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

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

Hope the above trick resolve your issue.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...