mapbox / node-pre-gyp

Node.js tool for easy binary deployment of C++ addons
BSD 3-Clause "New" or "Revised" License
1.12k stars 262 forks source link

Bypass HTTP download to use local binaries #574

Open dark-matter-matters opened 3 years ago

dark-matter-matters commented 3 years ago

Some packages do not have binaries for all platforms, like sqlite3. When trying to npm install it on arm64 arch, node-pre-gyp fails with a 403 error (node-pre-gyp: 0.17.0, npm 7.1.0, node 14.16.0), which is totally normal.

I could successfully build my own binaries for sqlite3, but the problem is that node-pre-gyp won't use them. When looking at the error stack, I could determine the path of the binaries:

npm ERR! node-pre-gyp info check checked for "root/project/server/node_modules/sqlite3/lib/binding/napi-v3-linux-arm64/node_sqlite3.node" (not found)

But I did place the node_sqlite3.node file there (also tried with the .tar.gz), it's readable and even 777'd. I don't understand this error... Looks like a bug as the file mentioned is right where it is supposed to be. Is there any reason why this isn't working, is there something else to do?

So my question is: how can I bypass the binary download and go directly to the unpack phase by providing locally the .node file?

springmeyer commented 3 years ago

One possible problem is that the path is "root/project/... instead of "/root/project.... In other words the path is ending up relative such that it is looking in the wrong place (given different working directory). Can you see where/why it is ending up as root/ instead of /root/? @dark-matter-matters

dark-matter-matters commented 3 years ago

For some reason placing the file locally would not work for me, pethaps because I must use an older version of node-pre-gyp on the target device. The only thing that worked was to upload the file on a mirror and pass it to node using --node_sqlite3_binary_host_mirror=https://somehost. Having to upload the file on Internet while it's available on the very same device is quite an overkill but it does the job...

phoenix-951 commented 1 month ago

where is the download bottom?