I know how to make an NPM dependency from a GitHub release :
"dependencies": {
"package-name": "user/repo#v1.0.0"
}
That's nice, but I want to install a specific binary from this release.
I tried
"dependencies": {
"package-name": "https://github.com/user/repo/releases/download/v1.0.0/bin.tgz"
}
But I gives me the following error :
❯ npm install
npm ERR! fetch failed https://github.com/user/repo/releases/download/v1.0.0/bin.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 404
Binary release assets exist outside of GitHub and are using AWS S3.
The URL github.com/user/repo/releases/download/v1.0.0/bin.tgz
is redirecting with a 302
status and a HTTP location header set to https://github-cloud.s3.amazonaws.com/releases/XXX/XXX...
If I try directly with the S3 URL I got a ENAMETOOLONG error (see NPM issue) :
> npm install https://github-cloud.s3.amazonaws.com/releases/XXX/XXX...
npm ERR! tarball.destroy is not a function
npm WARN retry will retry, error on last attempt: Error: ENAMETOOLONG: name too long, open '/var/folders/pn/......
Questions :
- Why is NPM not following the redirect?
- Why a
404
? - Is there a way to link an NPM dependency to a GitHub release's binary tarball? How?
My context and needs :
- I have a private GitHub repository
- My package needs to be built before "deploying" (transpilation, etc.)
- I want to "publish" a tarball of this build in my GitHub release and directly reference it to my NPM dependencies
- I use a CI service to build, make the tarball and upload it next to the GitHub release
- I would like to use GitHub release binary as a NPM repository
Related
- SO question: How to install an npm package from GitHub directly?
- NPM issue: https://github.com/npm/npm/issues/3055