Node.bcrypt.js: Have to use Python 2 for using bcrypt in latest stable node version?

Created on 8 Jan 2020  路  6Comments  路  Source: kelektiv/node.bcrypt.js

In Windows 10 OS, node version v12.14.0

npm i bcrypt

[email protected] install C:\Users\pc\Desktop\Node.js Projects\Secrets-Starting-Code\node_modules\bcrypt
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(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.7/bcrypt_lib-v3.0.7-node-v72-win32-x64-unknown.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
gyp ERR! find Python
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - executable path is "C:\Users\pc\AppData\Local\Programs\Python\Python37-32\python.exe"
gyp ERR! find Python - version is "3.7.4"
gyp ERR! find Python - version is 3.7.4 - should be >=2.6.0 <3.0.0
gyp ERR! find Python - THIS VERSION OF PYTHON IS NOT SUPPORTED
gyp ERR! find Python checking if "python2" can be used
gyp ERR! find Python - "python2" is not in PATH or produced an error
gyp ERR! find Python checking if the py launcher can be used to find Python 2
gyp ERR! find Python - "py.exe" is not in PATH or produced an error
gyp ERR! find Python checking if Python is C:\Python27\python.exe
gyp ERR! find Python - "C:\Python27\python.exe" could not be run
gyp ERR! find Python checking if Python is C:\Python37\python.exe
gyp ERR! find Python - "C:\Python37\python.exe" could not be run
gyp ERR! find Python
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python 2.7.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="C:\Path\To\python.exe"
gyp ERR! find Python (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python npm config set python "C:\Path\To\python.exe"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack at PythonFinder.fail (C:\Users\pc\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-python.js:303:47)
gyp ERR! stack at PythonFinder.runChecks (C:\Users\pc\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-python.js:132:21)
gyp ERR! stack at PythonFinder. (C:\Users\pc\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-python.js:221:16)
gyp ERR! stack at PythonFinder.execFileCallback (C:\Users\pc\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-python.js:267:16)
gyp ERR! stack at exithandler (child_process.js:302:5)
gyp ERR! stack at ChildProcess.errorhandler (child_process.js:314:5)
gyp ERR! stack at ChildProcess.emit (events.js:210:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
gyp ERR! stack at onErrorNT (internal/child_process.js:456:16)
gyp ERR! stack at processTicksAndRejections (internal/process/task_queues.js:80:21)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\pc\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\Users\pc\Desktop\Node.js Projects\Secrets-Starting-Code\node_modules\bcrypt\lib\binding\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=C:\Users\pc\Desktop\Node.js Projects\Secrets-Starting-Code\node_modules\bcrypt\lib\binding" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
gyp ERR! cwd C:\Users\pc\Desktop\Node.js Projects\Secrets-Starting-Code\node_modules\bcrypt
gyp ERR! node -v v12.14.0
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\pc\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Users\pc\Desktop\Node.js Projects\Secrets-Starting-Code\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\pc\Desktop\Node.js Projects\Secrets-Starting-Code\node_modules\bcrypt\lib\binding --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
node-pre-gyp ERR! stack at ChildProcess. (C:\Users\pc\Desktop\Node.js Projects\Secrets-Starting-Code\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:210:5)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
node-pre-gyp ERR! System Windows_NT 10.0.18363
node-pre-gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\pc\Desktop\Node.js Projects\Secrets-Starting-Code\node_modules\node-pre-gyp\bin\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\pc\Desktop\Node.js Projects\Secrets-Starting-Code\node_modules\bcrypt
node-pre-gyp ERR! node -v v12.14.0
node-pre-gyp ERR! node-pre-gyp -v v0.13.0
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\pc\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=C:\Users\pc\Desktop\Node.js Projects\Secrets-Starting-Code\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\pc\Desktop\Node.js Projects\Secrets-Starting-Code\node_modules\bcrypt\lib\binding --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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! C:\Users\pc\AppData\Roaming\npm-cache_logs\2020-01-08T06_31_17_623Z-debug.log

Most helpful comment

npm i [email protected]
it solved mine

All 6 comments

I was able to install bcrypt by doing the following on Windows 10 -

  1. npm install -g node-gyp
  2. Install all the required tools and configurations using Microsoft's windows-build-tools using npm install --global --production windows-build-tools from an elevated PowerShell or CMD.exe (run as Administrator). This step would install python 2.x
  3. npm config set msvs_version 2017
    Then running npm i bcrypt successfully installed - See below for log

$ npm i bcrypt

[email protected] install C:\Users\pc\Desktop\Node.js Projects\Secrets-Starting-Code\node_modules\bcrypt
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(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.7/bcrypt_lib-v3.0.7-node-v72-win32-x64-unknown.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
blowfish.cc
bcrypt.cc
bcrypt_node.cc
win_delay_load_hook.cc
Creating library C:\Users\pc\Desktop\Node.js Projects\Secrets-Starting-Code\node_modules\bcrypt\build\Release\bcry
pt_lib.lib and object C:\Users\pc\Desktop\Node.js Projects\Secrets-Starting-Code\node_modules\bcrypt\build\Release\bc
rypt_lib.exp
bcrypt_lib.vcxproj -> C:\Users\pc\Desktop\Node.js Projects\Secrets-Starting-Code\node_modules\bcrypt\build\Release\b
crypt_lib.node
Copying C:\Users\pc\Desktop\Node.js Projects\Secrets-Starting-Code\node_modules\bcrypt\build\Release\/bcrypt_lib.node
to C:/Users/pc/Desktop/Node.js Projects/Secrets-Starting-Code/node_modules/bcrypt/lib/binding\bcrypt_lib.node
1 file(s) copied.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

  • [email protected]
    added 64 packages from 46 contributors and audited 298 packages in 11.153s
    found 0 vulnerabilities

What a stupid design. I have wasted hours on this problem. 馃槨

Python versions depend on whatever is the node-gyp version bundled with your NodeJS installations.

Is there no node-bcrypt version that uses Python 3? Python 2 is officially deprecated as of January 1st, 2020

https://www.python.org/doc/sunset-python-2/

npm i [email protected]
it solved mine

@ronakdev It's not a bcrypt issue but the issue with NPM. NPM bundles its own version of node-gyp which requires Python 2. Newer NPM versions now bundle a node-gyp which is compatible with Python 3.

Either update npm or the node-gyp bundled with npm.

Was this page helpful?
0 / 5 - 0 ratings