Lock: Unable to import `auth0-lock/passwordless` or 'TypeError: Super expression must either be null or a function, not undefined'

Created on 8 Feb 2018  路  1Comment  路  Source: auth0/lock

As was confirmed in https://github.com/auth0/lock/issues/1256 - the import should be:

import Auth0LockPasswordless from 'auth0-lock/passwordless';

However, that would complain that it can't resolve auth0-lock/passwordless.

Thinking it might be my setup, I checked out your auth0-react-samples with the same effect - after ensuring that the module auth0-lock has the version 11.2.2 (which should have the passwordless support merged).

Looking at the module itself, there is however a lib folder so I was experimenting with that. You may stop me here as I shouldn't be doing that, but I am including it anyway.

I went ahead and changed the import:

import Auth0LockPasswordless from 'auth0-lock/lib/passwordless';

Now it can compile but fails at runtime trying to instantiate Auth0LockPasswordless:

Uncaught TypeError: Super expression must either be null or a function, not undefined
    at _inherits (bundle.js:82563)
    at bundle.js:82566
    at Object.<anonymous> (bundle.js:82578)
    at __webpack_require__ (bundle.js:556)
    at fn (bundle.js:87)
    at Object.<anonymous> (bundle.js:82289)
    at __webpack_require__ (bundle.js:556)
    at fn (bundle.js:87)
    at Object.<anonymous> (bundle.js:81380)
    at __webpack_require__ (bundle.js:556)

With the lines 82563 to 82566 being:

    function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

    var Auth0Lock = function (_Core) {
      _inherits(Auth0Lock, _Core);

This seem to come down to it not finding the base class (here _Core).

Interestingly, importing the index (either just auth0-lock or auth0-lock/lib/index) seem to make the auth0-lock/lib/passwordless import work.

Most helpful comment

Hi @de-code. Thanks for bringing this up. I think we got the export totally wrong for Passwordless. I just opened a PR to fix this and do proper exports for it. In v.12.2.3 (soon to be released), you'll be able to import it like:

import { Auth0LockPasswordless } from 'auth0-lock'

Thanks again!

>All comments

Hi @de-code. Thanks for bringing this up. I think we got the export totally wrong for Passwordless. I just opened a PR to fix this and do proper exports for it. In v.12.2.3 (soon to be released), you'll be able to import it like:

import { Auth0LockPasswordless } from 'auth0-lock'

Thanks again!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mcrawshaw picture mcrawshaw  路  5Comments

martsie picture martsie  路  5Comments

kjartanvalur picture kjartanvalur  路  8Comments

maxlapides picture maxlapides  路  5Comments

dszmaj picture dszmaj  路  3Comments