Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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

Ask Question

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.

@WaLidLamRaoui Yea its in the post, I managed to fix the issue though, however the VSCode extension still doesn't work so I'm not sure what's going on – crypthusiast0 Jun 10, 2021 at 23:50 yep .. i didn't see it, i think i need some rest for now, i updated the answer you need either use a correct version of nodejs or use npm to directlly install node-sqlite3 from github – WaLid LamRaoui Jun 10, 2021 at 23:53 can i ask what's the name of this extension? or could it be that you are developing one ? – WaLid LamRaoui Jun 10, 2021 at 23:57

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.

  • Q: Why can it not find the pre-built binaries?

  • A: Pre-built binaries are not so easy to manage because you need a lot more different versions of them than just the version of the npm package they are for. Usually, you need one for each major version of the npm package + version of node + operating system + instruction set architecture (e.g. ARM 32bit vs. x86 64bit etc.). It appears that, for some reason, Mapbox decided not to store those pre-built binaries for the long haul. I am sure they were there in the past, but for version 4.2.0 (and possibly many other versions), they are gone now.
  • They might only keep all those different binaries for the latest major version of their npm package and wipe old versions to save storage space. I have not found any documentation on that on their repo.
  • Q: What happens if it cannot download the pre-built binaries?

  • A: Things get very messy. Instead of a short download, it tries to compile them on your system, involving a complex labyrinth of system-level dependencies. For example:
  • In case of the OP, that compilation failed due to:

    gyp: No Xcode or CLT version detected!

  • In my case, it failed because (on Windows), I did not have VS 2017 (nor its redistributables) installed.
  • In general, local compilation firstly requires node-gyp to play along, and then you also need python and a system-specific C++ compiler. If you Google a little, you will find many stories of people succeeding (and failing) to get such local compilation to work. It is possible to aim for local compilation, but getting the pre-built binaries makes things a lot easier.
  • Using yarn and updating to the latest version of node-sqlite3 may resolve the issue of installing node-sqlite3 in your case , But the thing is if you read the Q carefully he specified that he needs node-sqlite3 version 4.2.0 so i think this is the easiest way to install that specific version of node-sqlite3 in his case – WaLid LamRaoui Jul 27, 2021 at 10:48 @WaLidLamRaoui It does not solve the problem though. If you want to solve the problem using 4.2.0 on their machine, and there are no pre-built binaries available, one needs to tackle the OP's system-specific compilation problems, i.e. gyp: No Xcode or CLT version detected!. The other answer does not explain how to solve that. – Domi Jul 27, 2021 at 13:03 @WaLidLamRaoui Thanks for the feedback. I added an explanation in case someone needs to target a specific version. – Domi Jul 27, 2021 at 17:06

    And since you didn't tell us wich version of node you are using it maybe related to not using a correct version of node it mentioned here that node-sqlite3 v4.2.0 works with :

  • Node.js v4.x, v6.x, v8.x, v10.x, v11.x, v12.x and v13.x.
  • so you may consider using the correct version of nodejs

    Alternatively

    If you're trying to install node-sqlite3 v4.2.0 manually from the source code. it's actually possible as mentioned here on the npm docs. Just make sure you are downloading the tarball file not the zip file one, in your case it should be this one

    Move the tarball where it should be, then simply run the following :

    npm install node-sqlite3-4.2.0.tar.gz
    

    Or even simpler :

    npm install https://github.com/mapbox/node-sqlite3/archive/refs/tags/v4.2.0.tar.gz
            

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.