I am attempting to use NPM in an environment behind a corporate firewall. Said firewall intercepts all https traffic and signs it with its' own CA... Is there a way to "trust" this CA so that NPM can actually work?
Asked
Active
Viewed 1.1k times
22
-
I realize that this may be more appropriate to another StackExchange site, but given it is specific to a particular development platform, I felt this was a more appropriate place. – Tracker1 Jun 10 '13 at 22:09
2 Answers
23
There is better way to configure npm to trust certificates issued by a specific CA.
npm config -g set cafile /path/to/myCA.cert
This will add this CA (probably your company's self signed certificate) to the npm's trusted CA's. With this solution, you get the benefit of SSL key validation and adding your own CA entities.

Josep Prat
- 493
- 5
- 11
-
1It's worth noting, that if you're forced through internal proxy, that the cert validation is pretty much meaningless anyway... – Tracker1 Jun 30 '16 at 21:04
-
[This answer](https://stackoverflow.com/a/27997570/185034) provides more detail and example for the `cafile` config property. – Paul Sep 14 '18 at 15:15
7
NOTE: This solution should not generally be used, see Josep's answer above as well as This Answer from comments. This question and answer were before the cafile options, iirc. Also, in my case it was behind a corporate proxy that self-signed everything anyway.
Old/Deprecated answer below.
Found the solution... (Ignoring SSL Certs)
npm config -g set strict-ssl false
Thanks to this thread in google groups.

Tracker1
- 19,103
- 12
- 80
- 106
-
2Warning: I believe this solution causes npm to accept ANY certificate. It would be better if there was an option to tell npm to trust only a specific certificate. – Scott Marchant May 12 '14 at 20:59
-
@ScottMarchant fair enough.. or for that matter, being able to add the internal CA chain... that said, the solution above works in the given environment. I had the same problems with git, and some other, similar issues in the end. – Tracker1 Jun 02 '14 at 18:06