Skip to content

Installation Instructions

Walter edited this page Mar 22, 2017 · 18 revisions

bcrypt is a native module for NodeJS, i.e, it uses native code to perform its work. The advantage of this over pure JS alternatives is speed. However, the disadvantage of this approach is it requires you to install a compiler and build dependencies in order to build.

We try to offer pre-built libraries for some platforms, but they are not always readily available since we developers do not own machines in all the architectures NodeJS is available for. Pre-compiled libraries for Windows, Linux and MacOS should be available and installed automatically by node-pre-gyp while installing bcrypt.

However, if the pre-compiled libraries are not yet available, or if you are willing to contribute to this library, you need to follow the instructions on this page.

Note: If precompiled binaries are not available, you will see an error like this:

node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v1.0.2/bcrypt_lib-v1.0.2-node-v48-linux-x64.tar.gz

This is not an error, npm install just falls back to compile from source, so it requires you to install a compiler. It is this part most users are facing errors. Make sure you have Python 2, a C++ compiler, and a make system installed.

The instructions in this page are not exhaustive and do not cover all platforms and distributions. If you get bcrypt installed on a platform not listed here, please edit this page and add your steps.

Linux

Linux machines come with a large variety of flavors and distributions. We only have instructions for the most commonly used distributions. However, you are welcome to contribute instructions for your distribution.

Note: In all cases, NodeJS 6.x and 7.x were installed from NodeSource repositories.

Ubuntu (and derivatives - Elementary, Linux Mint etc.)

Tested on:

  • Ubuntu 16.04.2 "Xenial Xerus" x64 (fresh install on AWS, Digital Ocean, Ubuntu Server ISO, Ubuntu desktop)
  • Elementary OS 0.4 "Loki" x64 (based on Ubuntu 16.04.1)
  • build-essential - In order to install a compiler chain to compile the node modules.
  • python (for server images, desktop images come with python installed) - 16.04 server defaults to python 3 so does not come with python 2. However, node-gyp requires python 2 to be installed.

This one liner should make sure all required packages are installed:

sudo apt-get install -y build-essential python

Fedora

Tested on:

  • Fedora 25 Workstation x64 (booted from Live CD, equivalent to fresh install)
  • Fedora 25 Server x64 (fresh install on DigitalOcean)
  • gcc-c++ - In order to install a compiler chain to compile the node modules.
  • make - To run the generated Makefile by node-gyp, which invokes compilers in order
  • python - Fedora Workstation come with the required version of python installed. In Fedora server, installing NodeJS also installs the required version of python
dnf install gcc-c++ make

RHEL and CentOS

Tested on:

  • CentOS 6.8
  • CentOS 7.3
  • RHEL 7.2

Derivatives like Amazon Linux and Oracle Linux should also work with these instructions as they mirror RHEL very closely. There have been reports of Amazon Linux working.

  • gcc-c++ - In order to install a compiler chain to compile the node modules.
  • make - To run the generated Makefile by node-gyp, which invokes compilers in order
  • python - RHEL and CentOS come with the required version of python installed

Make sure all dependencies are installed with this command, and then proceed with bcrypt installation

yum install -y gcc-c++ make

Microsoft Windows (w/o Visual Studio)

Tested on:

  • Windows 7 64Bit Professional (Service Pack 1)
  • Windows 10 64Bit Professional (Version 1607)

Open powershell with administrator privileges and run this command, then proceed with bcrypt installation

npm install --global --production windows-build-tools
Clone this wiki locally