`npm install` with a local network git repo is failing

The problem:
When I run npm i my-repo I get the following error:

fatal: unable to access 'https://my-repo-location/': SSL certificate problem: unable to get local issuer certificate

More Info:
my-repo is a git repository on my LAN accessible via https.

When I attempt using full verbosity, npm i -ddd my-repo, I get the following in the log output:

2 info using npm@6.9.0
3 info using node@v10.16.0
4 verbose npm-session 286251eeda21c649
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly fetchPackageMetaData error for my-repo@git+https://my-repo-location Error while executing:
7 silly fetchPackageMetaData C:\Program Files\Git\cmd\git.EXE ls-remote -h -t https://my-repo-location
7 silly fetchPackageMetaData
7 silly fetchPackageMetaData fatal: unable to access 'https://my-repo-location/': SSL certificate problem: unable to get local issuer certificate
7 silly fetchPackageMetaData
7 silly fetchPackageMetaData exited with error code: 128

Note:

  1. When I attempt the failing GIT command myself on the command line, C:\Program Files\Git\cmd\git.EXE ls-remote -h -t https://my-repo-location, it succeeds. So perhaps this is an issue with how npm itself runs git?
  2. my-repo-location uses a self-signed SSL certificate.
  3. I can reproduce this git error manually from the command line by removing the self-signed cert for my-repo-location from my custom sslcainfo file.

Question:
How do I npm install, or further debug the install, of this repository? Is there a way to pass the trace environment variables to the npm git call (eg: GIT_TRACE)?

Solved It
Adding the sslcainfo config to the system git config fixed the issue.

[http]
    sslCAInfo = C:/path/to/my/custom-ca-bundle.crt

The shell that npm runs git in (on Windows at least) does not use the git config for the user running the command, instead it uses only the system git config.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.