rest-api-nodejs-mongodb
                                
                                 rest-api-nodejs-mongodb copied to clipboard
                                
                                    rest-api-nodejs-mongodb copied to clipboard
                            
                            
                            
                        Getting error Error: Cannot find module 'bcrypt'
2021-07-19T09_57_53_633Z-debug.log
I have checked package json file but bcrypt package already available
Error: Cannot find module 'bcrypt' Require stack:
- E:\angular\kanhashoft\Node-With-Mongo\test\myproject\controllers\AuthController.js
- E:\angular\kanhashoft\Node-With-Mongo\test\myproject\routes\auth.js
- E:\angular\kanhashoft\Node-With-Mongo\test\myproject\routes\api.js
- E:\angular\kanhashoft\Node-With-Mongo\test\myproject\app.js
- E:\angular\kanhashoft\Node-With-Mongo\test\myproject\bin\www
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.(E:\angular\kanhashoft\Node-With-Mongo\test\myproject\controllers\AuthController.js:7:16) at Module._compile (internal/modules/cjs/loader.js:1085:14) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:14) at Module.require (internal/modules/cjs/loader.js:974:19) at require (internal/modules/cjs/helpers.js:92:18) at Object. (E:\angular\kanhashoft\Node-With-Mongo\test\myproject\routes\auth.js:2:24) at Module._compile (internal/modules/cjs/loader.js:1085:14) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:14) { code: 'MODULE_NOT_FOUND', requireStack: [ 'E:\angular\kanhashoft\Node-With-Mongo\test\myproject\controllers\AuthController.js', 'E:\angular\kanhashoft\Node-With-Mongo\test\myproject\routes\auth.js', 'E:\angular\kanhashoft\Node-With-Mongo\test\myproject\routes\api.js', 'E:\angular\kanhashoft\Node-With-Mongo\test\myproject\app.js', 'E:\angular\kanhashoft\Node-With-Mongo\test\myproject\bin\www' ] } 
node -v v14.17.2
Mongodb : 5.0.0
First:
npm uninstall bcrypt
second
npm install bcrypt
It will install newest bcrypt package.
You can even use bcryptjs
The below commands may solve your problem:
npm install node-gyp -g
npm install bcrypt -g
npm install bcrypt --save