无法在 Windows 11 和 Node 版本 20.11.0 上的 nextjs 项目中安装 bcrypt

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

这是运行命令后安装过程的完整日志:

npm i bcrypt
298 error code 1
299 error path E:\Learn\NextJS\Projects\2024-1-1\admin-dashboard\node_modules\bcrypt
300 error command failed
301 error command C:\Windows\system32\cmd.exe /d /s /c node-pre-gyp install --fallback-to-build
302 error Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\NaMaKaSh\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=E:\Learn\NextJS\Projects\2024-1-1\admin-dashboard\node_modules\bcrypt\lib\binding\napi-v3\bcrypt_lib.node --module_name=bcrypt_lib --module_path=E:\Learn\NextJS\Projects\2024-1-1\admin-dashboard\node_modules\bcrypt\lib\binding\napi-v3 --napi_version=9 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
303 error node-pre-gyp info it worked if it ends with ok
303 error node-pre-gyp info using [email protected]
303 error node-pre-gyp info using [email protected] | win32 | x64
303 error node-pre-gyp info check checked for "E:\Learn\NextJS\Projects\2024-1-1\admin-dashboard\node_modules\bcrypt\lib\binding\napi-v3\bcrypt_lib.node" (not found)
303 error 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
303 error node-pre-gyp ERR! install request to https://objects.githubusercontent.com/github-production-release-asset-2e65be/611333/97a8321c-5d46-45ec-b4ee-95fc5d5053fb?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVCODYLSA53PQK4ZA%2F20240206%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240206T010754Z&X-Amz-Expires=300&X-Amz-Signature=6c2e9b64564b4d28e537b620a92f3703c744c55eb68f4f0b6041e0d1dbcd0191&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=611333&response-content-disposition=attachment%3B%20filename%3Dbcrypt_lib-v5.1.1-napi-v3-win32-x64-unknown.tar.gz&response-content-type=application%2Foctet-stream failed, reason:  
303 error 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) 
303 error node-pre-gyp WARN Hit error request to https://objects.githubusercontent.com/github-production-release-asset-2e65be/611333/97a8321c-5d46-45ec-b4ee-95fc5d5053fb?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVCODYLSA53PQK4ZA%2F20240206%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240206T010754Z&X-Amz-Expires=300&X-Amz-Signature=6c2e9b64564b4d28e537b620a92f3703c744c55eb68f4f0b6041e0d1dbcd0191&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=611333&response-content-disposition=attachment%3B%20filename%3Dbcrypt_lib-v5.1.1-napi-v3-win32-x64-unknown.tar.gz&response-content-type=application%2Foctet-stream failed, reason:  
303 error gyp info it worked if it ends with ok
303 error gyp info using [email protected]
303 error gyp info using [email protected] | win32 | x64
303 error gyp info ok 
303 error gyp info it worked if it ends with ok
303 error gyp info using [email protected]
303 error gyp info using [email protected] | win32 | x64
303 error gyp info find Python using Python version 3.12.1 found at "C:\Users\NaMaKaSh\AppData\Local\Programs\Python\Python312\python.exe"
303 error gyp ERR! find VS 
303 error gyp ERR! find VS msvs_version not set from command line or npm config
303 error gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
303 error gyp ERR! find VS checking VS2022 (17.8.34525.116) found at:
303 error gyp ERR! find VS "C:\Program Files\Microsoft Visual Studio\2022\Community"
303 error gyp ERR! find VS - found "Visual Studio C++ core features"
303 error gyp ERR! find VS - missing any VC++ toolset
303 error gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
303 error gyp ERR! find VS not looking for VS2015 as it is only supported up to Node.js 18
303 error gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
303 error gyp ERR! find VS 
303 error gyp ERR! find VS **************************************************************
303 error gyp ERR! find VS You need to install the latest version of Visual Studio
303 error gyp ERR! find VS including the "Desktop development with C++" workload.
303 error gyp ERR! find VS For more information consult the documentation at:
303 error gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
303 error gyp ERR! find VS **************************************************************
303 error gyp ERR! find VS 
303 error gyp ERR! configure error 
303 error gyp ERR! stack Error: Could not find any Visual Studio installation to use
303 error gyp ERR! stack at VisualStudioFinder.fail (C:\Users\NaMaKaSh\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:113:11)
303 error gyp ERR! stack at VisualStudioFinder.findVisualStudio (C:\Users\NaMaKaSh\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:69:17)
303 error gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
303 error gyp ERR! stack at async createBuildDir (C:\Users\NaMaKaSh\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:69:26)
303 error gyp ERR! stack at async run (C:\Users\NaMaKaSh\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js:81:18)
303 error gyp ERR! System Windows_NT 10.0.22631
303 error gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\NaMaKaSh\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=E:\\Learn\\NextJS\\Projects\\2024-1-1\\admin-dashboard\\node_modules\\bcrypt\\lib\\binding\\napi-v3\\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=E:\\Learn\\NextJS\\Projects\\2024-1-1\\admin-dashboard\\node_modules\\bcrypt\\lib\\binding\\napi-v3" "--napi_version=9" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
303 error gyp ERR! cwd E:\Learn\NextJS\Projects\2024-1-1\admin-dashboard\node_modules\bcrypt
303 error gyp ERR! node -v v20.11.0
303 error gyp ERR! node-gyp -v v10.0.1
303 error gyp ERR! not ok 
303 error node-pre-gyp ERR! build error 
303 error node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\NaMaKaSh\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=E:\Learn\NextJS\Projects\2024-1-1\admin-dashboard\node_modules\bcrypt\lib\binding\napi-v3\bcrypt_lib.node --module_name=bcrypt_lib --module_path=E:\Learn\NextJS\Projects\2024-1-1\admin-dashboard\node_modules\bcrypt\lib\binding\napi-v3 --napi_version=9 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
303 error node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (E:\Learn\NextJS\Projects\2024-1-1\admin-dashboard\node_modules\@mapbox\node-pre-gyp\lib\util\compile.js:89:23)
303 error node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:518:28)
303 error node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1105:16)
303 error node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:305:5)
303 error node-pre-gyp ERR! System Windows_NT 10.0.22631
303 error node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "E:\\Learn\\NextJS\\Projects\\2024-1-1\\admin-dashboard\\node_modules\\@mapbox\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
303 error node-pre-gyp ERR! cwd E:\Learn\NextJS\Projects\2024-1-1\admin-dashboard\node_modules\bcrypt
303 error node-pre-gyp ERR! node -v v20.11.0
303 error node-pre-gyp ERR! node-pre-gyp -v v1.0.11
303 error node-pre-gyp ERR! not ok
304 verbose exit 1
305 timing npm Completed in 31026ms
306 verbose unfinished npm timer reify 1707181670391
307 verbose unfinished npm timer reify:build 1707181676014
308 verbose unfinished npm timer build 1707181676014
309 verbose unfinished npm timer build:deps 1707181676015
310 verbose unfinished npm timer build:run:install 1707181676027
311 verbose unfinished npm timer build:run:install:node_modules/bcrypt 1707181676027
312 verbose code 1
313 error A complete log of this run can be found in: C:\Users\NaMaKaSh\AppData\Local\npm-cache\_logs\2024-02-06T01_07_49_889Z-debug-0.log
node.js bcrypt node-pre-gyp
1个回答
0
投票

这就是解决问题的方法: 在 Windows 上 从 Microsoft Store 安装当前版本的 Python。

手动安装工具和配置:

安装 Visual C++ 构建环境:对于 Visual Studio 2019 或更高版本,请使用 Visual Studio 社区中的带有 C++ 工作负载的桌面开发。对于早于 Visual Studio 2019 的版本,请使用 Visual C++ 构建工具选项安装 Visual Studio 构建工具。 并在安装具有上述工作负载的 Visual Studio 并将路径变量设置为 MSBUILD.exe 后

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