Bcrypt JS issue

I have the following code and I can’t execute it because it doesn’t recognize bcryptjs when I try to dehash the password to see if it matches the user input. The error occurs at “this.result = Bcryptjs.compareSync(data, …”

import { Component } from '@angular/core';
import { ViewController, AlertController } from 'ionic-angular';
import * as Bcryptjs from "bcryptjs";

  templateUrl: 'popover.html'

export class GodMode {
  public hash: string;
  public result: boolean;

  constructor(public viewCtrl: ViewController, public alertCtrl: AlertController) { }

  authentication() {
let prompt = this.alertCtrl.create({
  title: 'Gode Mode Authentication',
  message: "Only the heads of the Scouting Team can access this",
  inputs : [
      name: 'Password',
      type: 'password',
      placeholder: 'Password'
  buttons: [
      text: 'Cancel',
      handler: data => {
        console.log('Exited Godmode prompt');
      text: 'Authenticate',
      handler: data =>{
        this.result = Bcryptjs.compareSync(data, "$2a$06$BLaLTSB8AixB.bd4OLNKuOc.CXMS/I27haszcgITbN6niSuAZhv1y");

  close() {

If you don’t get any better answers, you might try emulating the import syntax from the test file:

import bcryptjs = require("bcryptjs");

I get a error when trying that. It tells me to use import * as Bcryptjs from “bcryptjs”; instead

Something else is going on, then, because the following works for me when I just drop it into the home page of a scratch project:

import * as bcrypt from 'bcryptjs';

bcrypt.genSalt(40).then((salt) => {

let compsync = bcrypt.compareSync('apple', 'banana');

I get ‘false’ and something that looks reasonable for genSalt()'s output, so bcrypt seems to be working. bcrypt 2.4.3 and types ^2.4.0.

I found the issue it was the input from the form…

Would you happen to know what I have to do to get the input from the form to bcrypt?

Not without seeing enough code that I can copy/paste into my scratchpad.

These are my two .ts files for this page

https://pastebin.com/raw/EC5PsTvB (popup)
https://pastebin.com/raw/PdT48qQe (main)

I put the popup in a separate ts file

Sorry, but that’s not enough to reproduce it.

How much would you need to reproduce it?

Take a new ionic starter project (I tend to use tabs as the template for my scratchpads, but it doesn’t matter much). Isolate enough code from your problem project so that you can copy it into the scratch project and see the problem. Then anybody else can do the same.

Hi Kim,

Did you got solution for this. Please let me know bcryptjs installation process for IONIC3 project

Any Solution for import Bcrypt to ionic v3?? please

I use const bcrypt = require(“bcrypt”);
but have error