我的角度应用程序中出现奇怪的构建错误。谁能指出我做错了什么。我正在尝试使用ADAL.js角度包集成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”的模板编译期间出错 装饰器不支持函数调用,但在'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"
]
}
}
如果需要更多参考,请告诉我。
答案 0 :(得分:0)
您似乎在尝试为项目使用Angular 6,但是adal-angular5
取决于Angular5。结果,同时安装了Angular 5和Angular 6,并且它们的类型定义冲突;您也可能在运行时遇到问题。要么将项目切换到Angular 5,要么尝试使用adal-angular4
,后者应该支持Angular 4和更高版本。