How to proxy node-sass packages through your Artifactory server with NPM.
Many organizations utilize the node-sass packages in their day-to-day operations. Some of them might even want to save and cache these packages for future references. In this guide, I will show how you can configure, download and cache node-sass packages to your Artifactory server.
- node.js and NPM installed on your local server
- Artifactory server up and running
1. Create an npm remote repository and set the following URL: https://registry.npmjs.org
Navigate to Artifactory >> Artifacts >> npm-remote >> Set Me Up button.
Run the following commands:
npm config set registry http://<SERVER_NAME>:<PORT>/artifactory/api/npm/npm-remotenpm login - Enter your Artifactory username and password, add an email address.
2. Create a Generic remote repository which proxies the following URL: https://github.com/sass/node-sass/releases/download
In the repository Advanced configuration page, scroll down, check the 'Bypass HEAD Requests' checkbox (in order to allow Artifactory to send GET requests, without first issuing a HEAD request).
3. Finally, edit the ~/.npmrc file. Set the "sass_binary_site" parameter to the generic remote repository you just created. For example:
sass_binary_site=http://<username>:<API Key>@<SERVER_NAME>:<PORT>/artifactory/<your-generic-remote-repository>* your API Key can be found in Artifactory >> Artifacts >> your-generic-remote-repository >> Set Me Up button. Insert your password and the API Key will be shown below
Note that the instructions here are referring to the local user ~/.npmrc file and NOT the project's .npmrc file.