I was following the tutorial on https://github.com/mxstbr/passport-magic-login, but it keeps yelling at me "TypeError: MagicLoginStrategy is not a constructor" when running the code. Following is my code.
@auth.js
import MagicLoginStrategy from "passport-magic-login"
const magicLogin = new MagicLoginStrategy({...});
export default magicLogin;
@app.js
import magicLogin from './auth.js';
...
passport.use(magicLogin);
Why does it keep yelling the error? I also checked the MagicLoginStrategy, it was as follows.
class MagicLoginStrategy {
private _options;
...
constructor(_options: Options);
...
}
export default MagicLoginStrategy;
I think i'm calling the right constructor, and I don't know why I'm facing the errors. Thanks in advance.
CodePudding user response:
import MagicLoginStrategy from "passport-magic-login";
const magicLogin = new MagicLoginStrategy.default();
It's loading the CommonJS dist file instead of the ESM file.