node-email-verification icon indicating copy to clipboard operation
node-email-verification copied to clipboard

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. When createTempUser is called

Open mmccor26 opened this issue 5 years ago • 8 comments

mmccor26 avatar Nov 16 '19 17:11 mmccor26

This error occurs when you call the function events.js:174 throw er; // Unhandled 'error' event ^

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function at Object.randomBytes (internal/crypto/random.js:48:11) at Object.options.source (/home/ubuntu/environment/se3316-mmccor26-lab5/node_modules/rand-token/index.js:60:25) at Object.generate (/home/ubuntu/environment/se3316-mmccor26-lab5/node_modules/rand-token/index.js:95:29) at /home/ubuntu/environment/se3316-mmccor26-lab5/node_modules/email-verification/index.js:286:58 at /home/ubuntu/environment/se3316-mmccor26-lab5/node_modules/mongoose/lib/model.js:4604:16 at /home/ubuntu/environment/se3316-mmccor26-lab5/node_modules/mongoose/lib/query.js:4351:12 at model.Query.Query._completeOne (/home/ubuntu/environment/se3316-mmccor26-lab5/node_modules/mongoose/lib/query.js:2054:12) at Immediate.Query.base.findOne.call (/home/ubuntu/environment/se3316-mmccor26-lab5/node_modules/mongoose/lib/query.js:2116:10) at Immediate. (/home/ubuntu/environment/se3316-mmccor26-lab5/node_modules/mquery/lib/utils.js:116:16) at runCallback (timers.js:705:18) at tryOnImmediate (timers.js:676:5) at processImmediate (timers.js:658:5) Emitted 'error' event at: at /home/ubuntu/environment/se3316-mmccor26-lab5/node_modules/mongoose/lib/model.js:4606:13 at /home/ubuntu/environment/se3316-mmccor26-lab5/node_modules/mongoose/lib/query.js:4351:12 [... lines matching original stack trace ...] at processImmediate (timers.js:658:5) Waiting for the debugger to disconnect...

mmccor26 avatar Nov 16 '19 17:11 mmccor26

This exact error is destroying me lol

Isaac-Leanos avatar Dec 23 '19 02:12 Isaac-Leanos

Is there a answer for this? I am getting the same error

KKKaneki avatar Mar 11 '20 16:03 KKKaneki

I'm getting it to...

Flo2410 avatar Mar 19 '20 23:03 Flo2410

This package is too old. It's not compatible with new node (v9 up). It is using old version of rand-token package when this issue was not fixed. Please take a look here for more information: https://github.com/sehrope/node-rand-token/issues/10

datnguyen293 avatar Oct 16 '20 02:10 datnguyen293

It is very simple fix I made by the fork here: https://github.com/datnguyen293/node-email-verification

I also created a pull request to original repository: https://github.com/whitef0x0/node-email-verification/pull/89

datnguyen293 avatar Oct 16 '20 02:10 datnguyen293

as a temporary solution you can:

  1. add "rand-token": "^0.4.0" to your package.json
  2. use npm shrinkwrap
  3. change in npm-shrinkwrap.json
"email-verification": {
      "version": "0.4.6",
      "resolved": "https://registry.npmjs.org/email-verification/-/email-verification-0.4.6.tgz",
      "integrity": "sha1-DFRXJ/1onS12hWZvUbaLRMc5QkA=",
      "requires": {
        "mongoose": "~3.8.0",
        "nodemailer": "^1.3.0",
        "rand-token": "^0.4.0"
      },

MatviiStelmakh avatar Dec 06 '20 12:12 MatviiStelmakh

Aahh guys! After 3 hours I finally found it! rand-token doesn't work.

Opening the Issues tab to read this page oh wait.. - nevermind.

andrei-deeyu avatar Jan 03 '21 14:01 andrei-deeyu