Node-sass: How to download node-sass/.../v4.5.3/win32-x64-48_binding.node through Nexus ?

Created on 12 Oct 2017  ·  5Comments  ·  Source: sass/node-sass

Hi There,

We face to a problem regarding the component hereafter: sass v4.5.3 win32-x64-48_binding.node

Let's explain the context...
The developers machines have no access at all to internet.
No way to open internet on developers machine. It's strictly forbidden. That's like this!

The only way to get components from worldwide registies is through our Nexus Repository Manager instance wich is configurerd to proxy the "https://registry.npmjs.org/" registry.

On the deverlopers machines, the command "npm install" is launched.
The download trace showes that all npm artifacts and their dependencies are downloaded through our Nexus proxy, except one component that the sass npm module tries to get directly from internet:
https://github.com/sass/node-sass/releases/download/v4.5.3/win32-x64-48_binding.node

As workaround, our developers ask the internet Team to retrieve the concerned artifact win32-x64-48_binding.node, then they add it to the local folder "[...]node_modules\node-sass\vendor\win32-x64-48".
Finally, they launch a "npm rebuild node-sass" command to workaround the problem.

Of course, we face the same problem on our CI [Continuous Integration] platform: no internet access allowed. Manually maintaining the binary on the CI servers is not the best option.
Especially if the binary version is candidate to change in a future release of node-sass component.

Is there a way to force the download of the "binding_node" binary through our Nexus instead of a direct internet access ?

Regards.
O. Lambotte

Most helpful comment

To complete the answer of @Cuel with more details.

First, download the "Win32-x64-48 binding.node" from node-sass GitHub repository.
Then use curl command to upload the binary into your Nexus RM:

curl –k -v --user 'nexus_username:nexus_password' --upload-file C:\temp\win32-x64-48_binding.node https://nexus-rm-url/repository/Repo-name/v4.5.3/win32-x64-48_binding.node

Do not forget to set version of the binary in the destination repository.

We used Nexus RM 3.2.0-01. The format of the destination repository is raw.

To be fully transparent with developers we add the following setting in the NPM file “npmrc”:

sass_binary_site=https://nexus-rm-url/repository/Repo-name

If your Nexus do not allow anonymous access for contents download, you can fill the username/token in the URL:

sass_binary_site=https://token_username:token_password@nexus-rm-url/repository/Repo-name

Note that if your token has specials characters you have to “URL encode” them.

Now when you type “npm install node-sass” the package is fully installed with the extra binary file downloaded from Nexus RM.

All 5 comments

You can upload the file(s) to nexus using curl. I don't remember if the repo has to be called github.com. Don't forget to have a folder with the version number.

To complete the answer of @Cuel with more details.

First, download the "Win32-x64-48 binding.node" from node-sass GitHub repository.
Then use curl command to upload the binary into your Nexus RM:

curl –k -v --user 'nexus_username:nexus_password' --upload-file C:\temp\win32-x64-48_binding.node https://nexus-rm-url/repository/Repo-name/v4.5.3/win32-x64-48_binding.node

Do not forget to set version of the binary in the destination repository.

We used Nexus RM 3.2.0-01. The format of the destination repository is raw.

To be fully transparent with developers we add the following setting in the NPM file “npmrc”:

sass_binary_site=https://nexus-rm-url/repository/Repo-name

If your Nexus do not allow anonymous access for contents download, you can fill the username/token in the URL:

sass_binary_site=https://token_username:token_password@nexus-rm-url/repository/Repo-name

Note that if your token has specials characters you have to “URL encode” them.

Now when you type “npm install node-sass” the package is fully installed with the extra binary file downloaded from Nexus RM.

Thanks for the answer @Fizcko

I am getting 400 bad request error while trying to upload binding node to nexus using curl. Any inputs is highly appreciated. FYI, I am uploading linux-x64-57 binding node of node-sass

@rohit2307 We got 400 bad request " Non URL-safe name", because of running Nexus behind an Apache as ReverseProxy, see https://issues.sonatype.org/browse/NEXUS-11630

Was this page helpful?
0 / 5 - 0 ratings