1

I'm attempting to install express using the node package manager and am getting the below error. This is on Windows 7 x64 running cmd as administrator. Any assistance?

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\>npm install express -g
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/express
npm ERR! Error: SELF_SIGNED_CERT_IN_CHAIN
npm ERR!     at SecurePair.<anonymous> (tls.js:1283:32)
npm ERR!     at SecurePair.EventEmitter.emit (events.js:92:17)
npm ERR!     at SecurePair.maybeInitFinished (tls.js:896:10)
npm ERR!     at CleartextStream.read [as _read] (tls.js:430:15)
npm ERR!     at CleartextStream.Readable.read (_stream_readable.js:304:10)
npm ERR!     at EncryptedStream.write [as _write] (tls.js:344:25)
npm ERR!     at doWrite (_stream_writable.js:211:10)
npm ERR!     at writeOrBuffer (_stream_writable.js:201:5)
npm ERR!     at EncryptedStream.Writable.write (_stream_writable.js:172:11)
npm ERR!     at write (_stream_readable.js:557:24)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "express" "-g"
npm ERR! cwd C:\
npm ERR! node -v v0.10.5
npm ERR! npm -v 1.2.18
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\npm-debug.log
npm ERR! not ok code 0

I can connect to http://registry.npmjs.org/express in Chrome returning JSON

abc123
  • 17,855
  • 7
  • 52
  • 82
  • for the SELF_SIGNED_CERT_IN_CHAIN error check http://stackoverflow.com/questions/9626990/receiving-error-error-ssl-error-self-signed-cert-in-chain-while-using-npm – hcpl Feb 28 '14 at 12:51

1 Answers1

4

You'll notice if you connect to https://registry.npmjs.org/, Chrome will give you an SSL error since registry.npmjs.org is serving up a self-signed SSL certificate. registry.npmjs.org now uses a proper CA-signed certificate.

There are two possibilities:

  • Your npm config is messed up. Delete everything npm-related and reinstall.
  • If you're in an environment with an intercepting HTTPS proxy, it is likely breaking npm. Talk to your network administrator.
josh3736
  • 139,160
  • 33
  • 216
  • 263
  • 2
    I believe this to be correct, the network part this worked immediately at home with the newest version...I'll look into it more tomorrow while at work and see if the network admins see the same failure. – abc123 May 14 '13 at 03:47
  • i have upgraded my node and npm. I seem to have 4 certificates. But I still get the error. Any more ideas? – Alex B Feb 28 '14 at 02:07
  • 1
    @AlexB: My npm also has 4 certs now, and I've noticed that registry.npmjs.org now uses a proper CA-signed certificate that should validate by default. Since npm no longer uses a self-signed certificate, it's most likely that you are on a network with an intercepting HTTPS proxy. Talk to your network administrator. – josh3736 Feb 28 '14 at 02:31
  • Network administrator here. From what I can tell NPM doesn't use the system's certificate store (unless you're on redhat?). It uses a CA store from NPM source, so there's no way to add the intercepting proxy cert to the trust store. – apocalysque Jun 29 '22 at 15:55
  • 1
    @apocalysque: You are correct; npm does not use the system CA store (except RHEL and derivatives, because that distro modifies npm's behavior). On other distros/platforms, you need to [manually configure your npm to use an alternate root CA](https://stackoverflow.com/a/27997570/201952), taking care to note that this completely overrides npm's CA bundle, so for npm to work on corp networks and regular networks, you need to add both the intercepting proxy's CA *and* the usual public CAs. – josh3736 Jul 07 '22 at 01:01