Npm 无法安装 bcrypt node-pre-gyp

问题描述 投票:0回答:1

当我尝试运行 npm i bcrypt 时,出现以下错误

PS C:\Users\Barth\OneDrive\Bureaublad\School\Semester 6\Individual project\Stat-Tracker-Application\Authentication-api> npm i bcrypt
npm ERR! code 1
npm ERR! path C:\Users\Barth\OneDrive\Bureaublad\School\Semester 6\Individual project\Stat-Tracker-Application\Authentication-Api\node_modules\bcrypt
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-pre-gyp install --fallback-to-build
npm ERR! Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Users\Barth\OneDrive\Bureaublad\School\Semester 6\Individual project\Stat-Tracker-Application\Authentication-Api\node_modules\bcrypt\lib\binding\napi-v3\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\Barth\OneDrive\Bureaublad\School\Semester 6\Individual project\Stat-Tracker-Application\Authentication-Api\node_modules\bcrypt\lib\binding\napi-v3 --napi_version=9 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using [email protected]
npm ERR! node-pre-gyp info using [email protected] | win32 | x64
npm ERR! node-pre-gyp info check checked for "C:\Users\Barth\OneDrive\Bureaublad\School\Semester 6\Individual project\Stat-Tracker-Application\Authentication-Api\node_modules\bcrypt\lib\binding\napi-v3\bcrypt_lib.node" (not found)
npm ERR! node-pre-gyp http GET https://github.com/kelektiv/node.bcrypt.js/releases/download/v5.1.1/bcrypt_lib-v5.1.1-napi-v3-win32-x64-unknown.tar.gz
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v115 ABI, unknown) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp WARN Hit error ENOENT: no such file or directory, open 'C:\Certs\root_ca.pem'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp info find Python using Python version 3.11.5 found at "C:\Python311\python.exe"
npm ERR! gyp http GET https://nodejs.org/download/release/v20.9.0/node-v20.9.0-headers.tar.gz
npm ERR! gyp WARN install got an error, rolling back install
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: ENOENT: no such file or directory, open 'C:\Certs\root_ca.pem'
npm ERR! gyp ERR! System Windows_NT 10.0.22621
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\\Users\\Barth\\OneDrive\\Bureaublad\\School\\Semester 6\\Individual project\\Stat-Tracker-Application\\Authentication-Api\\node_modules\\bcrypt\\lib\\binding\\napi-v3\\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=C:\\Users\\Barth\\OneDrive\\Bureaublad\\School\\Semester 6\\Individual project\\Stat-Tracker-Application\\Authentication-Api\\node_modules\\bcrypt\\lib\\binding\\napi-v3" "--napi_version=9" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
npm ERR! gyp ERR! cwd C:\Users\Barth\OneDrive\Bureaublad\School\Semester 6\Individual project\Stat-Tracker-Application\Authentication-Api\node_modules\bcrypt
npm ERR! gyp ERR! node -v v20.9.0
npm ERR! gyp ERR! node-gyp -v v9.4.0
npm ERR! gyp ERR! not ok
npm ERR! node-pre-gyp ERR! build error
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Users\Barth\OneDrive\Bureaublad\School\Semester 6\Individual project\Stat-Tracker-Application\Authentication-Api\node_modules\bcrypt\lib\binding\napi-v3\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\Barth\OneDrive\Bureaublad\School\Semester 6\Individual project\Stat-Tracker-Application\Authentication-Api\node_modules\bcrypt\lib\binding\napi-v3 --napi_version=9 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\Barth\OneDrive\Bureaublad\School\Semester 6\Individual project\Stat-Tracker-Application\Authentication-Api\node_modules\@mapbox\node-pre-gyp\lib\util\compile.js:89:23)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
npm ERR! node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1105:16)
npm ERR! node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:305:5)
npm ERR! node-pre-gyp ERR! System Windows_NT 10.0.22621
npm ERR! node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Barth\\OneDrive\\Bureaublad\\School\\Semester 6\\Individual project\\Stat-Tracker-Application\\Authentication-Api\\node_modules\\@mapbox\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd C:\Users\Barth\OneDrive\Bureaublad\School\Semester 6\Individual project\Stat-Tracker-Application\Authentication-Api\node_modules\bcrypt
npm ERR! node-pre-gyp ERR! node -v v20.9.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.11
npm ERR! node-pre-gyp ERR! not ok

这似乎与无法找到名为 root_ca.pem 的文件有关 为什么它甚至在寻找这个 我弄乱了什么环境变量以及如何修复它

node.js bcrypt node-pre-gyp
1个回答
0
投票

看看这个

简单的解决方案就是从“bcrypt”npm 模块切换到 bcryptjsbcrypt-nodejs。这是完全相同的 API,但纯 JS,因此无需处理本机附加组件。

npm install --save bcryptjs && npm uninstall --save bcrypt

然后将您的

require
调用更改为“bcryptjs”,但其他所有代码都可以保持不变。

从长远来看,我怀疑目前 bcrypt 可能还没有为节点 v0.12.0 做好准备,但如果没有,它最终会更新并准备好。

© www.soinside.com 2019 - 2024. All rights reserved.