Npm config set cafile install#
$env:NODE_EXTRA_CA_CERTS=path\to\certificate.pem npm install worked for me in Windows Powershell.įor DOS/cmd (pointed out by Marc in the comments) set NODE_EXTRA_CA_CERTS=C:\\path\\to\\certificate. Changing my cafile setting: npm config set cafile /path/to/your/cert.pem Stop rejecting unknown CAs: set NODETLSREJECTUNAUTHORIZED0. RHEL Note: If you happen to be using a RHEL based distro and the RHEL packaged nodejs/npm you can use the standard update-ca-trust method as RedHat points their packages at the system CA's.
Npm config set cafile code#
Unfortunately npm's CA bundle is not editable as it's provided in the source code (thanks tomekwi) but nitzel has provided a generic Node.js method to append a certificate via the NODE_EXTRA_CA_CERTS environment variable. If you need to support both public https npm registries as well as your own, you could use curl's Mozilla based CA bundle and append your CA cert to the cacert.pem file: curl > ~/. If you try and use any public npm registries via https that aren't signed by your CA certificate, you will get errors.
Note: these CA settings will override the default "real world" certificate authority lookups that npm uses. The npm config commands above will persist the relevant config items to your ~/.npmrc file: cafile=/path/to/cert.pem npm config set ca "cert string"Ĭa can be an array of cert strings too. You can also configure ca string(s) directly. npmrc: ca'cert 1 base64 string' ca'cert 2 base64 string' The npm config commands above will persist the relevant config items to your /.npmrc. npm config set ca 'cert string' ca can be an array of cert strings too. This directory is primarily accessed through pacote, the library responsible for all package fetching as of npm5. This directory is a cacache -based content-addressable cache that stores all http request data as well as other package-related data. For example, if the package.You can point npm to a cafile npm config set cafile /path/to/cert.pem npm config set cafile /path/to/cert.pem You can also configure ca string(s) directly. npm stores cache data in an opaque directory within the configured cache, named cacache. When running scripts (see npm-scripts) the package.json "config" keys are overwritten in the environment if there is a config param of ]. Npm ls -global -parseable -long -loglevel info If multiple single-character shorthands are strung together, and the resulting combination is unambiguously not some other configuration param, then it is expanded to its various component pieces. If the specified configuration param resolves unambiguously to a known configuration parameter, then it is expanded to that configuration parameter.
The following shorthands are parsed on the command-line: Windows/MacOS/Linux npm config set cafileRun npm config ls -l to see a set of configuration parameters that are internal to npm, and are defaults if nothing else is specified. Npm builtin config file (/path/to/npm/npmrc) Per-project config file (/path/to/my/project/.npmrc)
Config values are case-insensitive, so NPM_CONFIG_FOO=bar will work the same. Edit 2: Keep in mind that setting npm config set cafileAny environment configurations that are not given a value will be given the value of true. npm's built-in configuration file (/path/to/npm/npmrc) See npmrc for more details.
For example, putting npm_config_foo=bar in your environment will set the foo configuration parameter to bar. A -flag parameter that is at the end of the command will be given the value of true.Īny environment variables that start with npm config will be interpreted as a configuration parameter. A - argument tells the cli parser to stop reading flags. Putting -foo bar on the command line sets the foo configuration parameter to "bar". Npm gets its configuration values from the following sources, sorted by priority:
More than you probably want to know about npm configuration