How to configure .npmrc file to be able to combine different NPM registries?

3.4k Views Asked by At

How to set an .npmrc file to tell npm install to download all the dependencies from https://registry.npmjs.org but only a specific one from a corporate Artifactory under https://artifactory.corporation.io/artifactory/npm/ that needs authentication using ?

1

There are 1 best solutions below

2
Tatarao Vana On BEST ANSWER

We can configure https://registry.npmjs.org as a remote repository(test-npm-remote) in Artifactory. If you have any packages which were developed locally can be deployed to the local(test-npm-local) repository. We can create a virtual repository that consists of local and remote repositories and pull the npm artifacts using the virtual repository(test-npm). You can find more details in the below link. https://jfrog.com/screencast/setting-up-an-npm-registry-with-jfrog-artifactory-in-less-than-one-minute/

npm config set registry http://art.local/artifactory/api/npm/test-npm/
npm login
<enter credentials>

Sample NPM client configuration for your reference.

$ cat ~/.npmrc                                                                    
[email protected]
always-auth=true
registry=http://art.local/artifactory/api/npm/test-npm/
//art.local/artifactory/api/npm/test-npm/:username=testuser
//art.local/artifactory/api/npm/test-npm/:_password=XXXXXXX

To install a package: npm install <PACKAGE_NAME>