node.jsbcryptnode-pre-gyp

Can not install bcrypt in a nextjs project on windows 11 and node version 20.11.0


Here is a complete log of installing process , after running the command:

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 node-pre-gyp@1.0.11
303 error node-pre-gyp info using node@20.11.0 | 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 bcrypt@5.1.1 and node@20.11.0 (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 node-gyp@10.0.1
303 error gyp info using node@20.11.0 | win32 | x64
303 error gyp info ok 
303 error gyp info it worked if it ends with ok
303 error gyp info using node-gyp@10.0.1
303 error gyp info using node@20.11.0 | 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

Solution

  • This is what solved the proplem: On Windows Install the current version of Python from the Microsoft Store.

    Install tools and configuration manually:

    Install Visual C++ Build Environment: For Visual Studio 2019 or later, use the Desktop development with C++ workload from Visual Studio Community. For a version older than Visual Studio 2019, install Visual Studio Build Tools with the Visual C++ build tools option. and after installing visual studio with the mentioned workload and setting path variable to MSBUILD.exe