Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to "npm install" bcrypt on Windows 7

I've installed node.js v6.9.1 together with npm version 4.1.2 and I've already used this combination for some projects

Now I wanted to use the bcrypt npm package in my project, but the installation fails miserably

npm install bcrypt --save

I've also tried to run this command with admin priviledges, to no avail

This is the error I get

> [email protected] install C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcry
pt
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcryp
t.js/releases/download/v1.0.2/bcrypt_lib-v1.0.2-node-v48-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (
node-v48 ABI) (falling back to source compile with node-gyp)

C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt>if not defined npm_c
onfig_node_gyp (node "C:\Users\ttheiner\AppData\Roaming\npm\node_modules\npm\bin
\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" clean )  else (node
"" clean )

C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt>if not defined npm_c
onfig_node_gyp (node "C:\Users\ttheiner\AppData\Roaming\npm\node_modules\npm\bin
\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" configure --fallback
-to-build --module=C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt\l
ib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\tthei
ner\NodeProjects\authtest\node_modules\bcrypt\lib\binding )  else (node "" confi
gure --fallback-to-build --module=C:\Users\ttheiner\NodeProjects\authtest\node_m
odules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path
=C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt\lib\binding )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT
HON env variable.
gyp ERR! stack     at Object.failNoPython (C:\Users\ttheiner\AppData\Roaming\npm
\node_modules\npm\node_modules\node-gyp\lib\configure.js:454:19)
gyp ERR! stack     at Object.<anonymous> (C:\Users\ttheiner\AppData\Roaming\npm\
node_modules\npm\node_modules\node-gyp\lib\configure.js:480:16)
gyp ERR! stack     at C:\Users\ttheiner\AppData\Roaming\npm\node_modules\npm\nod
e_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:123:15)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\ttheiner\\App
Data\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js"
 "configure" "--fallback-to-build" "--module=C:\\Users\\ttheiner\\NodeProjects\\
authtest\\node_modules\\bcrypt\\lib\\binding\\bcrypt_lib.node" "--module_name=bc
rypt_lib" "--module_path=C:\\Users\\ttheiner\\NodeProjects\\authtest\\node_modul
es\\bcrypt\\lib\\binding"
gyp ERR! cwd C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt
gyp ERR! node -v v6.9.1
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd configure --fallb
ack-to-build --module=C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcryp
t\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\tt
heiner\NodeProjects\authtest\node_modules\bcrypt\lib\binding' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\ttheiner\NodeP
rojects\authtest\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:877:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/chi
ld_process.js:226:5)
node-pre-gyp ERR! System Windows_NT 6.1.7601
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\tthe
iner\\NodeProjects\\authtest\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "in
stall" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcryp
t
node-pre-gyp ERR! node -v v6.9.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.32
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd configure --fallback-to-build --module=C:\Users\
ttheiner\NodeProjects\authtest\node_modules\bcrypt\lib\binding\bcrypt_lib.node -
-module_name=bcrypt_lib --module_path=C:\Users\ttheiner\NodeProjects\authtest\no
de_modules\bcrypt\lib\binding' (1)
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\ttheiner\\AppDat
a\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "bcrypt" "--save"

npm ERR! node v6.9.1
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE

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 'node-pre-gyp install --fallb
ack-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bcrypt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs bcrypt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls bcrypt
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\ttheiner\NodeProjects\authtest\npm-debug.log

The problem seems to be that npm cannot find pre-built binaries so it tries to compile the sources using python (which I don't seem to have).

Do I need to install python for this? If yes, can you point me in the right direction? Is it true that there is no pre-built version of bcrypt?

EDIT: After installing Python 2.7 the error changes... seems like it tries to use MSBuild to compile some C++ code.

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(366,5): warning MSB8003: Could not find WindowsSDKDir var
iable from the registry.  TargetFrameworkVersion or PlatformToolset may be set to an invalid version number. [C:\Users\ttheiner\NodeProject
s\authtest\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
TRACKER : error TRK0005: Failed to locate: "CL.exe". The system cannot find the file specified. [C:\Users\ttheiner\NodeProjects\authtest\no
de_modules\bcrypt\build\bcrypt_lib.vcxproj]


gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\ttheiner\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)

gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\ttheiner\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gy
p\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\Users\\ttheiner\\NodeProjects\\authtest\\node_modules\\bcrypt\\lib\\binding
\\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=C:\\Users\\ttheiner\\NodeProjects\\authtest\\node_modules\\bcrypt\\lib\\binding
"
gyp ERR! cwd C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt
gyp ERR! node -v v6.9.1
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd build --fallback-to-build --module=C:\Users\ttheiner\NodeProjects\authtest\no
de_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\ttheiner\NodeProjects\authtest\node_modules\bc
rypt\lib\binding' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\ttheiner\NodeProjects\authtest\node_modules\node-pre-gyp\lib\util\compile.
js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:877:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
node-pre-gyp ERR! System Windows_NT 6.1.7601
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\ttheiner\\NodeProjects\\authtest\\node_modules\\node-pre-gyp\\bi
n\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt
node-pre-gyp ERR! node -v v6.9.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.32
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd build --fallback-to-build --module=C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt\lib\binding\b
crypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt\lib\binding' (1)
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.
npm WARN Error: EPERM: operation not permitted, scandir 'C:\Users\ttheiner\NodeProjects\authtest\node_modules\dashdash\node_modules'
npm WARN     at Error (native)
npm WARN  { Error: EPERM: operation not permitted, scandir 'C:\Users\ttheiner\NodeProjects\authtest\node_modules\dashdash\node_modules'
npm WARN     at Error (native)
npm WARN   errno: -4048,
npm WARN   code: 'EPERM',
npm WARN   syscall: 'scandir',
npm WARN   path: 'C:\\Users\\ttheiner\\NodeProjects\\authtest\\node_modules\\dashdash\\node_modules' }
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\ttheiner\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "instal
l" "bcrypt" "--save"
npm ERR! node v6.9.1
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE

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 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bcrypt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs bcrypt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls bcrypt
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\ttheiner\NodeProjects\authtest\npm-debug.log
like image 235
devnull69 Avatar asked Jan 27 '17 17:01

devnull69


People also ask

Can I use bcrypt with npm?

Using npm, it forces you to use python 2.7 while there is a perfectly functional version of bcrypt for python 3(used it in the past). I recommend using a node-centric package instead of bcrypt or detaching its use from npm and running it separately with python 3.

How to install and update bcrypt in Linux?

You can installing bcrypt npm packages, there are two ways to install this module locally and globaly. -g option is specified to global. Execute the below command. $ sudo npm install bcrypt $ sudo npm install -g bcrypt If want to update the bcrypt package execute the command as below,

How to install and update bcrypt in NodeJS?

bcrypt : A bcrypt library for NodeJS.. You can installing bcrypt npm packages, there are two ways to install this module locally and globaly. -g option is specified to global. Execute the below command. If want to update the bcrypt package execute the command as below,

How do I run NPM on Windows 7?

Access to the Windows command line (search > cmd > right-click > run as administrator) OR Windows PowerShell (Search > Powershell > right-click > run as administrator) Note: If you want to install the run-time environment on a different operating system, check out our guide on installing Node.js and NPM on CentOS 7 .


3 Answers

I also faced the same issue today whilst trying to install bcrypt on Windows 10 desktop. Turns out that bcrypt support stable versions of node better check out the docs

The solution for me was:

  1. Upgrade node to a stable version: I manually downloaded and installed Windows installer from Node website.
  2. Install the Windows build tools globally: npm install --global --production windows-build-tools
  3. Finally npm install bcrypt --save

After this everything worked ok.

like image 119
Moe Avatar answered Oct 26 '22 09:10

Moe


I would suggest you use bcrypt-nodejs:

https://www.npmjs.com/package/bcrypt-nodejs

It provides almost the same functionality with easy usage.

Original answer:

Can you try the following:

  1. Install Python (http://www.python.org/download/releases/2.7.5/)
  2. Install Visual Studio 2012/13 Express (or other)
  3. Install Windows SDK (for Windows 7 / 8)
  4. Install Win64 OpenSSL v1.0.1g
  5. Open "Developer Command Prompt for VS2012" as Administrator and test install

Then:

  • npm install node-gyp -g
  • npm install bcrypt -g
like image 37
Pankaj kumar Panigrahi Avatar answered Oct 26 '22 09:10

Pankaj kumar Panigrahi


I've had the same or at least a similar error. Running the following before trying to install bcrypt solved it for me:

npm install --global --production windows-build-tools
like image 34
Ricki-BumbleDev Avatar answered Oct 26 '22 08:10

Ricki-BumbleDev