Cannot find module 'bcrypt'

3 min read
Last updated at: Jul 01 2021

Developers Troubleshooting Installation and Setup

I have npm start server then show this message

Issue:-

 

I have npm start server then show this message

[nodemon] starting node -r ts-node/register src/app.ts
Error: Cannot find module 'bcrypt'
Require stack:

  • 
    
    [nodemon] starting node -r ts-node/register src/app.ts
    Error: Cannot find module 'bcrypt'
    Require stack:
    
    e:\anup\project\ecommerce3\Spurtcommerce-alpha-community-v2.2.0\api\src\api\models\User.ts
    e:\anup\project\ecommerce3\Spurtcommerce-alpha-community-v2.2.0\api\src\api\repositories\UserRepository.ts
    e:\anup\project\ecommerce3\Spurtcommerce-alpha-community-v2.2.0\api\src\auth\AuthService.ts
    e:\anup\project\ecommerce3\Spurtcommerce-alpha-community-v2.2.0\api\src\auth\authorizationChecker.ts
    e:\anup\project\ecommerce3\Spurtcommerce-alpha-community-v2.2.0\api\src\loaders\expressLoader.ts
    e:\anup\project\ecommerce3\Spurtcommerce-alpha-community-v2.2.0\api\src\app.ts
    at Function.Module.resolveFilename (internal/modules/cjs/loader.js:625:15)
    at Function.Module.load (internal/modules/cjs/loader.js:527:27)
    at Module.require (internal/modules/cjs/loader.js:683:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object.<anonymous> (e:\anup\project\ecommerce3\Spurtcommerce-alpha-community-v2.2.0\api\src\api\models\User.ts:11:1)
    at Module.compile (internal/modules/cjs/loader.js:777:30)
    at Module.m.compile (e:\anup\project\ecommerce3\Spurtcommerce-alpha-community-v2.2.0\api\node_modules\ts-node\src\index.ts:439:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:788:10)
    at Object.require.extensions.<computed> [as .ts] (e:\anup\project\ecommerce3\Spurtcommerce-alpha-community-v2.2.0\api\node_modules\ts-node\src\index.ts:442:12)
    at Module.load (internal/modules/cjs/loader.js:643:32)
    [nodemon] app crashed - waiting for file changes before starting...

 

Solution :

 

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

 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..