ARTIFACTORY: How to resolve NodeJS versions using Artifactory

ARTIFACTORY: How to resolve NodeJS versions using Artifactory

AuthorFullName__c
Md Mohsin Ali
articleNumber
000006171
ft:sourceType
Salesforce
FirstPublishedDate
2024-08-25T07:19:29Z
lastModifiedDate
2024-08-25
VersionNumber
1
Introduction:
This article explains the steps and configurations required in order to resolve NodeJS versions from https://nodejs.org without encountering rate limit on https://nodejs.org/dist endpoint. You may refer to this GitHub thread for additional information.

Artifactory side configuration:
To resolve NodeJS versions via Artifactory, we will be using a Generic Remote Repository on Artifactory pointing to NodeJS upstream.
1. Create a Generic Remote Repository(Ex: nodejs-versions-remote) on Artifactory. 

2. Configure the upstream URL with “https://nodejs.org/” and save the configuration. If we perform test connection, it results in forbidden(HTTP status code 403) error.
However, it will not block resolution of the required artifacts. The Forbidden is expected because the response code returned by the NodeJS upstream is 307 and Artifactory was expecting a 200 HTTP status code.

3. We can configure the NodeJS remote repository with our client to resolve the required versions. Please note that, currently the “Remote Repository Browsing” is not supported thus, we have to get the list of versions manually via the browser. Hence, we need to visit “https://nodejs.org/dist” and browse through the list of NodeJS versions available. 

4. Select required artifact name and supply it as part of the Client request to download and here is an example for the reference. 
curl -u <userName> -X GET "https://<Artifactory-URL>/artifactory/<generic-remoteRepoName>/dist/latest/node-v22.6.0-darwin-arm64.tar.gz" -O 

To verify, we can browse Generic Remote Repository cache for the downloaded artifact. We can also check the integrity of the downloaded file by executing the “shasum” and comare it against the checksums generated at Artifactory end.

Related Links
Generic Repositories
NPM Repository
​​​​​​​Use NPM Command Line