node.jsnpmnode-gyp

Cannot download node-sqlite3@4.2.0 - node-pre-gyp ERROR Tried to download(403) Access Denied - node.js


I've been trying to download sqlite3@4.2.0, however it's been giving me an error. Here are the logs when trying to run npm install:

npm WARN deprecated node-pre-gyp@0.11.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future

> sqlite3@4.2.0 install /Users/crypthusiast0/Dev/nodejs/auction-flipper/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using needle for node-pre-gyp https download 
node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.2.0/node-v83-darwin-arm64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for sqlite3@4.2.0 and node@14.17.0 (node-v83 ABI, unknown) (falling back to source compile with node-gyp) 
No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.

gyp: No Xcode or CLT version detected!
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/crypthusiast0/.nvm/versions/node/v14.17.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:376:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Darwin 20.4.0
gyp ERR! command "/Users/crypthusiast0/.nvm/versions/node/v14.17.0/bin/node" "/Users/crypthusiast0/.nvm/versions/node/v14.17.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/crypthusiast0/Dev/nodejs/auction-flipper/node_modules/sqlite3/lib/binding/node-v83-darwin-arm64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/Users/crypthusiast0/Dev/nodejs/auction-flipper/node_modules/sqlite3/lib/binding/node-v83-darwin-arm64" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v83"
gyp ERR! cwd /Users/crypthusiast0/Dev/nodejs/auction-flipper/node_modules/sqlite3
gyp ERR! node -v v14.17.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/Users/crypthusiast0/.nvm/versions/node/v14.17.0/bin/node /Users/crypthusiast0/.nvm/versions/node/v14.17.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/crypthusiast0/Dev/nodejs/auction-flipper/node_modules/sqlite3/lib/binding/node-v83-darwin-arm64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/crypthusiast0/Dev/nodejs/auction-flipper/node_modules/sqlite3/lib/binding/node-v83-darwin-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/crypthusiast0/Dev/nodejs/auction-flipper/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:376:20)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1055:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
node-pre-gyp ERR! System Darwin 20.4.0
node-pre-gyp ERR! command "/Users/crypthusiast0/.nvm/versions/node/v14.17.0/bin/node" "/Users/crypthusiast0/Dev/nodejs/auction-flipper/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/crypthusiast0/Dev/nodejs/auction-flipper/node_modules/sqlite3
node-pre-gyp ERR! node -v v14.17.0
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok 
Failed to execute '/Users/crypthusiast0/.nvm/versions/node/v14.17.0/bin/node /Users/crypthusiast0/.nvm/versions/node/v14.17.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/crypthusiast0/Dev/nodejs/auction-flipper/node_modules/sqlite3/lib/binding/node-v83-darwin-arm64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/crypthusiast0/Dev/nodejs/auction-flipper/node_modules/sqlite3/lib/binding/node-v83-darwin-arm64 --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)
npm WARN node-auction-flipper@0.1.0 No repository field.
npm WARN node-auction-flipper@0.1.0 license should be a valid SPDX license expression

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sqlite3@4.2.0 install: `node - pre - gyp install--fallback - to - build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sqlite3@4.2.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/crypthusiast0/.npm/_logs/2021-06-10T21_46_58_721Z-debug.log

I looked back at the logs to see that https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.2.0/node-v83-darwin-arm64.tar.gz is probably the main cause of this because if you actually go to the link, it gives you this error:

<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>Q0JKD48B1117QG62</RequestId>
<HostId>0tR6ildiySR62EjZI4DwfeVbxSFIOClQUiIyMCySpd/lficx42uEJ2YU94GtQQvMnF4EENuWH/0=</HostId>
</Error>

I'n not entirely sure how to fix this because I'm not very experienced with Node.js/NPM and installing modules, however I do need node-sqlite3 specifically version 4.2.0 because one of my VSCode extensions relies on it. I have found the github repo of node-sqlite and the 4.2.0 source code. Is there any way to fix this or compile the module from source? Maybe could it be because it's not supported on my node version/os? I had this working before so I'm not sure.

I'm on a MacBook Air M1 (ARM) running node version v16.3.0 and npm version v7.16.0.


Solution

  • The other answer is not helpful in my case. Also, I found that simply using yarn instead of npm solves the issues mentioned by the other answer.

    However, that answer does not address the main issue:

    node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.2.0/node-*******.tar.gz

    node-pre-gyp WARN Pre-built binaries not found

    TL;DR

    For me, upgrading to latest sqlite3 (e.g. via yarn add "sqlite3@^5" (NOTE: this command does not work properly in powershell)) fixes this issue. The reason for that is: it finds the pre-built binaries for this version just fine.

    If you (absolutely) NEED to use an older version, you will have to make sure, the local compilation succeeds, as explained below.

    In addition to that, you also want to make sure, you have a somewhat recent version of node installed, because often times, pre-built binaries are commonly not provided for out-of-date Node versions (check node -v; recommendation: use volta to manage your node version).

    Warning: Of course, those pre-built binaries might also be removed by the package author in the near fututure. Hopefully, they will at least replace them with a newer version, and not just take them offline entirely.

    Explanation

    The error message above indicates that gyp was not able to download the system-specific pre-built binaries (which is very different from the npm package). Because it cannot find the pre-built binaries, it would try to compile them locally, which is always messy and can easily go wrong.