Cannot find module 'bcrypt'

前端 未结 30 2987
轻奢々
轻奢々 2020-12-24 01:54

I am getting error Cannot find module \'bcrypt\' in nodejs application

I have tried to install it using npm install bcrypt but still gett

相关标签:
30条回答
  • 2020-12-24 02:45

    You need to update the g++ compiler version in your linux system. To update the compiler just run the commands below:

    sudo add-apt-repository ppa:ubuntu-toolchain-r/test
    
    sudo apt-get update
    
    sudo apt-get install gcc-4.9 g++-4.9
    
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9
    
    
    npm install bcrypt --save
    
    0 讨论(0)
  • 2020-12-24 02:45

    Be sure you are in a stable version of node too. If you are working with n, you only need to:

    sudo n stable
    

    And then again:

    npm install bcrypt --save
    

    And it worked for me.

    0 讨论(0)
  • 2020-12-24 02:46

    If this is an error you are facing when using something like Travis CI, consider using npm install --build-from-source.

    0 讨论(0)
  • 2020-12-24 02:47

    Check your node version and then go to this link https://github.com/kelektiv/node.bcrypt.js to match compatible bcrypt version with your node.js version

    I am using node.js v14.7.0 and when I tried to run 'npm install bcrypt or bcryptjs' it gives me errors then I run npm install bcrypt@5.0.0

    and the error fixed.

    Version Compatibility

    0 讨论(0)
  • 2020-12-24 02:47

    From: Cannot find module 'bcrypt'

    Use bcrypt version according to node version.

    Try to install bcrypt npm package separately like this If your node version is 8 use this command line

    npm install bcrypt@1 --save

    If your node version is 10,11 use this command line

    npm install bcrypt@3 --save

    maybe its will help you..

    PS For me the second cmd worked and my Node version is 14.

    0 讨论(0)
  • 2020-12-24 02:48

    In my case, npm rebuild alone didn't solved it. I also had to:

    $ npm install -g node-gyp
    $ sudo apt-get update
    $ sudo apt-get install build-essential
    $ npm rebuild
    

    npm rebuild was trying to run make.

    0 讨论(0)
提交回复
热议问题