【发布时间】:2019-01-26 12:02:24
【问题描述】:
我的 Angular 应用程序出现奇怪的构建错误。谁能指出我做错了什么。我正在尝试使用 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"
]
}
}
如果需要更多参考,请告诉我。
【问题讨论】:
-
能否请您发布您的 tsconfig.json。
-
我已经更新了详细信息。如果有任何问题,请告诉我。
标签: angular typescript angular-cli