1. Set Up an Artifactory Repository
Install JFrog Artifactory: First, ensure you have JFrog Artifactory installed and running. You can follow the installation guide provided by JFrog.
2. In the Artifactory UI, create a new npm Remote Repository and configure the following fields:
3. Then configure your npm client to use your Artifactory repository. You can do this using the npm config command:
npm config set registry https://<artifactory-url>/artifactory/api/npm/<npm-repo-name>
Replace <artifactory-url> with the URL of your Artifactory instance and <npm-repo-name> with the name of your npm repository.
If your npm registry requires authentication, you'll need to configure your npm client to use the credentials:
npm login --registry https://<artifactory-url>/artifactory/api/npm/<npm-remote-repo-name>
You'll be prompted to enter your Artifactory credentials.
Kindly follow NPM Private package for a more detailed explanation
Install JFrog Artifactory: First, ensure you have JFrog Artifactory installed and running. You can follow the installation guide provided by JFrog.
2. In the Artifactory UI, create a new npm Remote Repository and configure the following fields:
- Username - enter the username of your npmjs.com account.
- Password / Access Token - enter your npmjs.com Granular Access Token or Classic Token.
- Enable Token Authentication - check this checkbox.
After filling in the fields, click Test Connection to verify that Artifactory can authenticate to npmjs.com successfully, then save the repository.
Note
Do not leave the username blank or use a dummy value. A valid npmjs.com username and a valid token generated on the npmjs.com website are required. 3. Then configure your npm client to use your Artifactory repository. You can do this using the npm config command:
npm config set registry https://<artifactory-url>/artifactory/api/npm/<npm-repo-name>
Replace <artifactory-url> with the URL of your Artifactory instance and <npm-repo-name> with the name of your npm repository.
If your npm registry requires authentication, you'll need to configure your npm client to use the credentials:
npm login --registry https://<artifactory-url>/artifactory/api/npm/<npm-remote-repo-name>
You'll be prompted to enter your Artifactory credentials.
Kindly follow NPM Private package for a more detailed explanation
4. Install the private npm packages using the following,
npm install --registry https://<artifactory-url>/artifactory/api/npm/<npm-remote-repo-name> <package-name>
Replace <package-name> with the name of the private package you want to install.
5. Here are the sample log entries while resolving npm private registry artifacts from our lab environment.
npm install --registry https://<artifactory-url>/artifactory/api/npm/<npm-remote-repo-name> <package-name>
Replace <package-name> with the name of the private package you want to install.
5. Here are the sample log entries while resolving npm private registry artifacts from our lab environment.
==> artifactory-request.log <== 2023-10-17T15:37:53.887Z|41203552e33bab16|0.0.0.0|admin|GET|/api/npm/t-npm-remote/@testorg%2ftestpvtpkg|200|-1|0|645|npm/9.5.0 node/v19.7.0 darwin x64 workspaces/false ==> artifactory-request-out.log <== 2023-10-17T15:37:53.529Z|41203552e33bab16|t-npm-remote|testjfrog|HEAD|https://registry.npmjs.org/@testorg%2Ftestpvtpkg|200|0|0|282 2023-10-17T15:37:53.696Z|41203552e33bab16|t-npm-remote|testjfrog|GET|https://registry.npmjs.org/@testorg%2Ftestpvtpkg|200|0|1467|160 ==> artifactory-access.log <== 2023-10-17T15:37:53.705Z [41203552e33bab16] [ACCEPTED DEPLOY] t-npm-remote-cache:.npm/@testorg/testpvtpkg/package.json for client : admin/X.X.X.X
Note: Do not leave the username blank or don't include any dummy username in the field. We need to pass a valid username and token generated on the NPMJS website.