Introduction
There is a npm website https://buf.build/gen/npm/v1 which can be used as a source to install packages, but to directly proxy it by npm remote repository does not work with 404 error.
Root Cause and Resolution
Due to npm installing packages from https://buf.build/gen/npm/v1 will also install from https://registry.npmjs.org, which needs to use two npm remote repositories to proxy separately.
Use npm repository to proxy:
-
Create npm-remote to proxy https://registry.npmjs.org;
-
Create npm-remote-buf to proxy https://buf.build/gen/npm/v1 (It must check “Bypass Header Request” at Advanced page due to the site is not supported about Head request);
-
Then configure client to connect the two above remote repositories;
And .npmrc like:
@buf:registry=https://demo.com/artifactory/api/npm/npm-remote-buf/
//demo.com/artifactory/api/npm/npm-remote-buf/:_authToken=<token>
registry=https://demo.com/artifactory/api/npm/npm-remote/
//demo.com/artifactory/api/npm/npm-remote/:_authToken=<token>
Conclusion
After that, ‘npm install <package> --verbose’ will install from Artifactory successfully.