问题描述
我正在将我的 Angular 应用程序从 gulp 移植到 Webpack 和 ES6.我正在使用 auth0 进行身份验证,并按照 auth0 此处的教程进行操作:
I'm porting my Angular app from gulp over to Webpack and ES6. I'm using auth0 for authentication, and following the tutorial from auth0 here:
https://auth0.com/docs/quickstart/spa/angularjs
我的版本是:
- 角度 1.5.8
- 角度锁定 1.0.1
- auth0-lock 10.2.2
我正在苦苦挣扎的是我在加载应用程序时遇到的这个错误:
What I'm strugling with is this error I get when I'm loading up my app:
Failed to instantiate module app due to:
Error: [$injector:modulerr] Failed to instantiate module auth0.lock due to:
Error: Auth0Lock must be loaded.
我有一个 libraries.js 文件,我在其中导入了所有依赖项:
I have a libraries.js file where I import all my dependencies:
import 'auth0-lock';
import 'angular-lock';
import 'angular-jwt';
在我的 index.js 中,我有以下设置:
and in my index.js I have the following setup:
import './libraries';
import './app/home/home-component';
import './app/shared/security/authService';
module.exports = angular
.module('app',
['ui.router', 'ui.bootstrap', 'auth0.lock', 'angular-jwt', 'app.homeModule', 'shared.authModule'])
.config(configFunction)
.run(runFunction);
我尝试在我的 webpack.config.js 中添加这个插件但没有成功:
I have tried adding this plugin in my webpack.config.js with no luck:
new webpack.ProvidePlugin({
Auth0Lock: "auth0-lock",
}),
关于如何在 angular-lock 加载之前加载我的 Auth0Lock 有什么想法吗?我认为这会发生,因为我首先重视它,但显然不是.
Any ideas of how I can make my Auth0Lock be loaded before the angular-lock loads? I thought that was going to happen since I important it first, but apperantly not.
非常感谢任何帮助.
推荐答案
我相信 auth0-angular 在 window 对象中寻找 Auth0Lock.尝试通过更改为:
I believe auth0-angular looks for Auth0Lock in the window object. Try changing the name of the global variable by changing to:
new webpack.ProvidePlugin({
"window.Auth0Lock": "auth0-lock"
}),
这篇关于使用 Angular 1.5.8 和 Webpack 的 Auth0 锁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!