Search code examples
javascriptnode.jsexpressrecaptcha

TypeError: Recaptcha is not a constructor


Suddenly my app stopped compiling due to this TypeError: Recaptcha is not a constructor.

    recaptchaConfig() {
        this.recaptcha = new Recaptcha(
            config.service.recaptcha.client_key,
            config.service.recaptcha.secret_key , 
            {...config.service.recaptcha.options}
        );
    }

It was working just fine, and now I don't know what caused it. https://github.com/arya107/AskArya-Node.js-Vue.js/blob/master/Server/app/http/controllers/controller.js


Solution

  • Just tried your code and with:

    var Recaptcha = require('express-recaptcha').Recaptcha;
    

    got the sam exception, but if you try:

    var Recaptcha = require('express-recaptcha').RecaptchaV3;
    

    it works, try it.