简体   繁体   English

无法下载 node-sqlite3@4.2.0 - node-pre-gyp 错误尝试下载(403)访问被拒绝 - node.js

[英]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.我一直在尝试下载sqlite3@4.2.0 ,但是它一直给我一个错误。 Here are the logs when trying to run npm install :以下是尝试运行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:我回头查看日志,发现https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.2.0/node-v83-darwin-arm64.tar.gz可能是主要原因,因为如果您实际上是 go 到链接,它会给您这个错误:

<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.我不完全确定如何解决这个问题,因为我对 Node.js/NPM 和安装模块不是很有经验,但是我确实需要node-sqlite3特别是版本4.2.0 ,因为我的 VSCode 扩展之一依赖它。 I have found the github repo of node-sqlite and the 4.2.0 source code.我找到了node-sqlite的 github repo 和4.2.0源代码。 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.我在运行节点版本 v16.3.0 和 npm 版本 v7.16.0 的 MacBook Air M1 (ARM) 上。

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.另外,我发现简单地使用yarn代替npm解决了另一个答案提到的问题。

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 尝试下载(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.2.0/node-*******.tar.gz

node-pre-gyp WARN Pre-built binaries not found node-pre-gyp WARN 未找到预构建的二进制文件

TL;DR TL;博士

For me, upgrading to latest sqlite3 (eg via yarn add sqlite3@^5 ) fixes this issue.对我来说,升级到最新的sqlite3 (例如通过yarn add sqlite3@^5 )可以解决这个问题。 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).除此之外,您还需要确保安装了最新版本的node ,因为通常不会为过时的节点版本提供预构建的二进制文件(检查node -v ;建议:使用volta管理您的节点版本)。

Warning: Of course, those pre-built binaries might also be removed by the package author in the near fututure.警告:当然,package 作者在不久的将来也可能删除这些预构建的二进制文件。 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).上面的错误消息表明gyp无法下载系统特定的预构建二进制文件(这与npm包有很大不同)。 Because it cannot find the pre-built binaries, it would try to compile them locally, which is always messy and can easily go wrong.因为它找不到预构建的二进制文件,它会尝试在本地编译它们,这总是很混乱,很容易出错 go 。

  • 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.答:预构建的二进制文件不太容易管理,因为您需要它们的更多不同版本,而不仅仅是它们所用的npm package 版本。 Usually, you need one for each major version of the npm package + version of node + operating system + instruction set architecture (eg ARM 32bit vs. x86 64bit etc.). Usually, you need one for each major version of the npm package + version of node + operating system + instruction set architecture (eg 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.似乎出于某种原因,Mapbox 决定不长期存储这些预构建的二进制文件。 I am sure they were there in the past, but for version 4.2.0 (and possibly many other versions), they are gone now.我确信它们过去存在,但是对于 4.2.0 版(可能还有许多其他版本),它们现在已经消失了。
    • 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.他们可能只为他们的npm package 的最新主要版本保留所有这些不同的二进制文件,并擦除旧版本以节省存储空间。 I have not found any documentation on that on their repo .在他们的 repo上没有找到任何相关文档。
  • Q: What happens if it cannot download the pre-built binaries?问:如果无法下载预构建的二进制文件会怎样?

    • A: Things get very messy. A:事情变得非常混乱。 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:在 OP 的情况下,编译失败的原因是:

        gyp: No Xcode or CLT version detected! gyp:未检测到 Xcode 或 CLT 版本!

      • In my case, it failed because (on Windows), I did not have VS 2017 installed.就我而言,它失败了,因为(在 Windows 上)我没有安装VS 2017
    • In general, local compilation firstly requires node-gyp to play along, and then you also need python and a system-specific C++ compiler.一般来说,本地编译首先需要node-gyp gyp配合,然后还需要python和系统专用的C++编译器。 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.可以针对本地编译,但是获取预构建的二进制文件会使事情变得容易得多。

For fixing the errors try the following:要修复错误,请尝试以下操作:

  • clean the npm cache清理 npm 缓存

     npm cache clean
  • run npm install and see if it's working运行 npm 安装并查看它是否工作

     npm install

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-sqlite3 v4.2.0 可以使用:

  • Node.js v4.x, v6.x, v8.x, v10.x, v11.x, v12.x and v13.x. Node.js v4.x、v6.x、v8.x、v10.x、v11.x、v12.x 和 v13.x。

so you may consider using the correct version of nodejs所以你可以考虑使用正确版本的nodejs


Alternatively或者

If you're trying to install node-sqlite3 v4.2.0 manually from the source code.如果您尝试从源代码手动安装node-sqlite3 v4.2.0 it's actually possible as mentioned here on the npm docs .正如 npm文档中提到的,这实际上是可能的。 Just make sure you are downloading the tarball file not the zip file one, in your case it should be this one只要确保您下载的是 tarball 文件而不是 zip 文件之一,在您的情况下应该是这个文件

Move the tarball where it should be, then simply run the following:将 tarball 移动到应有的位置,然后只需运行以下命令:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 节点预gyp错误! 在 windows 10 中迁移时尝试下载 (404) - node-pre-gyp ERR! Tried to download(404) while migration in windows 10 NPM 问题:Node-pre-gyp。 使用 node-pre-gyp https 下载请求 - NPM PROBLEM: Node-pre-gyp. Using request for node-pre-gyp https download 安装 sqlite3 时 node-pre-gyp 出错 - Error with node-pre-gyp when installing sqlite3 Webpack:ERROR in ./~/sqlite3/~/node-pre-gyp/lib/node-pre-gyp.js找不到模块:错误:无法解析&#39;file&#39;或&#39;directory&#39;../package - Webpack: ERROR in ./~/sqlite3/~/node-pre-gyp/lib/node-pre-gyp.js Module not found: Error: Cannot resolve 'file' or 'directory' ../package bcrypt npm 安装错误 - 错误:找不到模块 node-pre-gyp\bin\node-pre-gyp - bcrypt npm install error - Error: Cannot find module node-pre-gyp\bin\node-pre-gyp NPM 安装错误 - 节点预 Gyp - NPM Install Error - Node-Pre-Gyp 由于与节点可能发生冲突,导致节点预gyp安装错误 - node-pre-gyp install error due to possible conflict with node 在 Yocto 的节点上安装 sqlite3 显示错误 node-pre-gyp ERR: stack Error: Failed to execute '/usr/local/bin/node - Installing sqlite3 on node in Yocto showing Error node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node 如何修复 npm install node-pre-gyp ERR 错误 - How to fix the npm install node-pre-gyp ERR error 由于 node-pre-gyp 错误,无法安装 npm - Couldn't install npm because of a node-pre-gyp error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM