我的角度应用程序中出现了奇怪的构建错误。谁能指出我做错了什么?我正在尝试使用adal.js angular包集成azure ad身份验证。我用adal-angular5
来做这个。
cli命令:ng serve
node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11)中出错:错误ts2451:无法重新声明块范围变量“ngdevmode”。
node_modules/adal-angular5/node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11):错误ts2451:无法重新声明块范围变量“ngdevmode”。
与ng build --prod
一起使用时
@angular\common\http\http.ts(62,2)中的错误:“httpclient”的模板编译期间出错
decorators不支持函数调用,但在“injectable”中调用了“_makedecorator”
“injectable”调用“makedecorator”。
node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11):错误ts2451:无法重新声明块范围变量“ngdevmode”。
node_modules/adal-angular5/node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11):错误ts2451:无法重新声明块范围变量“ngdevmode”。
这是我的角度版本细节
Angular CLI: 6.1.4
Node: 8.11.4
OS: win32 x64
Angular: 6.1.3
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.7.4
@angular-devkit/build-angular 0.7.4
@angular-devkit/build-optimizer 0.7.4
@angular-devkit/build-webpack 0.7.4
@angular-devkit/core 0.7.4
@angular-devkit/schematics 0.7.4
@angular/cli 6.1.4
@ngtools/webpack 6.1.4
@schematics/angular 0.7.4
@schematics/update 0.7.4
rxjs 6.2.2
typescript 2.9.2
webpack 4.9.2
我的app.moudle.ts供参考:
import { AuthService } from './services/auth.service';
import { AuthGuardService } from './services/auth-gurad.service';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { ProtectedComponent } from './protected/protected.component';
import { AuthCallbackComponent } from './auth-callback/auth-
callback.component';
import { Adal5Service, Adal5HTTPService } from 'adal-angular5';
import { HttpClient } from '@angular/common/http';
const routes: Routes = [
{
path:'',
children: []
},
{
path:'protected',
component:ProtectedComponent,
canActivate: [AuthGuardService]
},
{
path:'auth-callback',
component:AuthCallbackComponent
}
];
@NgModule({
declarations: [
AppComponent,
ProtectedComponent,
AuthCallbackComponent
],
imports: [
BrowserModule,
RouterModule.forRoot(routes)
],
exports: [RouterModule],
providers: [AuthGuardService, AuthService, Adal5Service,{
provide:Adal5HTTPService, useFactory:Adal5HTTPService.factory, deps:
[HttpClient, Adal5Service] } ],
bootstrap: [AppComponent]
})
export class AppModule { }
这是我的tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
如果需要更多的参考,请告诉我。
最佳答案
看起来您试图在项目中使用Angular6,但adal-angular5
取决于Angular5。因此,安装了Angular5和Angular6,它们的类型定义相互冲突;您在运行时也可能遇到问题。请将项目切换到Angular5或尝试adal-angular4
,它应该支持Angular4和更新版本。