My app was working with Angular 2, but it stopped working now that I’ve changed to Angular 4.
What causes problem is that before I was using:
// Avoid name not found warnings
let Auth0Lock = require('auth0-lock').default;
But now that gives me this error:
ERROR in /blablabla…/services/auth.service.ts (6,17): Cannot find name 'require'.
So I’ve tried a lot of possible configurations, including the new guide in https://auth0.com/docs/quickstart/spa/angular2/01-login that suggest to use:
declare var Auth0Lock: any;
but I kept getting errors, in this case:
MainNavigationComponent.html:2 ERROR ReferenceError: Auth0Lock is not defined
Unhandled Promise rejection: Auth0Lock is not defined ; Zone: <root> ; Task: Promise.then ; Value: ReferenceError: Auth0Lock is not defined
My working solution was to go into node_modules/auth0-lock/lib/index.js and change
exports.default = Auth0Lock;
into
exports.Auth0Lock = Auth0Lock;
While using
import { Auth0Lock } from "auth0-lock";
To import it, which worked perfectly.
However editing stuff in node_modules is a bad idea, we all know that, but I cannot be blocked by this and I need to keep working while I find a better solution.
So how am I supposed to import Auth0Lock?
From my package.json:
"angular2-jwt": "^0.2.0",
"auth0-lock": "^10.14.0"