2017-11-27 16 views
0

구축 :오류가 나는 각 CLI 버전 1.5.2이 명령을 사용하여 생산을위한 각 버전 5 응용 프로그램 구축을 위해 노력하고

ng build --prod 

그러나 그것은 나에게이 오류 제공 :

ERROR in Error: Error encountered resolving symbol values statically. Calling fu nction 'FlashMessagesModule', function calls are not supported. Consider replaci ng the function or lambda with a reference to an exported function, resolving sy mbol AppModule in D:/Project/mean-auth-app/angular-src/src/app/app.module.ts, re solving symbol AppModule in D:/Project/mean-auth-app/angular-src/src/app/app.mod ule.ts

angular 버전 v5.0이 angular2-flash-messages 모듈 버전 2.0.0과 충돌합니다. 나는 플래시 메시지 모듈을 설치하고 설정하는 것과 정확히 똑같은 것을했다. here. 검색했지만 유용한 힌트를 찾을 수 없었습니다. 어떤 사람들은 그것을 버그라고 부르며, 문제가되는 패키지를 설치 제거하거나 설치하면 어떤 사람들은 문제를 해결할 수 있습니다.

내 응용 프로그램 모듈 :

import { BrowserModule } from '@angular/platform-browser'; 
 
import { NgModule } from '@angular/core'; 
 
import { FormsModule } from '@angular/forms'; 
 
import { RouterModule, Routes } from '@angular/router'; 
 
import { HttpModule } from '@angular/http'; 
 

 
import { AppComponent } from './app.component'; 
 
import { NavbarComponent } from './components/navbar/navbar.component'; 
 
import { LoginComponent } from './components/login/login.component'; 
 
import { RegisterComponent } from './components/register/register.component'; 
 
import { HomeComponent } from './components/home/home.component'; 
 
import { DashboardComponent } from './components/dashboard/dashboard.component'; 
 
import { ProfileComponent } from './components/profile/profile.component'; 
 
import { AccountService } from './services/account.service'; 
 

 
import { FlashMessagesModule } from 'angular2-flash-messages'; 
 
import { JwtModule } from '@auth0/angular-jwt'; 
 
import { HttpClientModule } from '@angular/common/http'; 
 
import { AuthGuard } from './services/auth-guard.service'; 
 

 
const routes = [ 
 
    { path: '', component: HomeComponent }, 
 
    { path: 'register', component: RegisterComponent }, 
 
    { path: 'login', component: LoginComponent }, 
 
    { path: 'dashboard', component: DashboardComponent, canActivate: [AuthGuard]}, 
 
    { path: 'profile', component: ProfileComponent, canActivate: [AuthGuard]} 
 
]; 
 

 
@NgModule({ 
 
    declarations: [ 
 
    AppComponent, 
 
    NavbarComponent, 
 
    LoginComponent, 
 
    RegisterComponent, 
 
    HomeComponent, 
 
    DashboardComponent, 
 
    ProfileComponent 
 
    ], 
 
    imports: [ 
 
    BrowserModule, 
 
    FormsModule, 
 
    HttpModule, 
 
    FlashMessagesModule.forRoot(), 
 
    RouterModule.forRoot(routes), 
 
    HttpClientModule, 
 
    JwtModule.forRoot({ 
 
     config: { 
 
     tokenGetter:() => { 
 
      return localStorage.getItem('token'); 
 
     }, 
 
     whitelistedDomains: ['localhost:4200'] 
 
     } 
 
    }) 
 
    ], 
 
    providers: [AccountService, AuthGuard], 
 
    bootstrap: [AppComponent] 
 
}) 
 
export class AppModule { }

나는이 문제를 해결하기 위해 어떤 힌트를 주셔서 감사합니다.

+0

는 말한다 : 당신은 실내 장식에 람다 기능을 사용할 수 없습니다. 'tokenGetter'가 참조하는 내 보낸 함수로 다시 작성하십시오. – Dinistro

+0

@Dinistro 답장을 보내 주셔서 감사합니다. 그러나 그것은 FlashMessagesModule을 언급했다. –

+0

'FlashMessagesModule'은이 에러의 원인이 아니다. – Dinistro

답변

2

편집 : 다음은 --prod 빌드도 손상 시키지만 다른 메시지가 표시됩니다.

angular2-flash-messages 패키지를 살펴 보았는데 오류는 코드에 있습니다. 각도 컴파일러의 필수 메타 데이터를 추가하지 않았습니다. 다음 문제가 해결 될 때까지 해결책이 없다 : https://github.com/moff/angular2-flash-messages/issues/31


올드 대답 : 당신은 장식에 람다 기능을 사용할 수 없습니다

.

오류

는 여기있다 :

config: { 
    tokenGetter:() => { // <- here 
     return localStorage.getItem('token'); 
    }, 
    whitelistedDomains: ['localhost:4200'] 
} 

문제는 각 당신이 람다 함수를 사용하는 경우 장식에 대해 필요한 모든 정보를 저장할 수 없습니다 것입니다,하지만 내 보낸 기능을 사용할 수 있습니다.

당신은 그것을 다시 작성해야 :

export function tokenGetter() { 
    return localStorage.getItem('token'); 
} 

그리고 당신은 당신의 코드에서 다음과 같이 사용할 수있을 것입니다 : 방지 AngularCLI의 tsconfig.json 내부 @angular하는 경로를 지정

config: { 
    tokenGetter: tokenGetter, 
    whitelistedDomains: ['localhost:4200'] 
} 
+0

나는 그 부분을 당신의 제안으로 바 꾸었습니다. 아직도 나에게 같은 오류를 준다 –

+0

@peymangilmour 메시지가 정확히 같은가요? 여전히 'AppModule'에 대해 언급하고 있습니까? – Dinistro

+0

예 및 오류 메시지 : –

0

일어나는 것으로부터의 오류.

"paths": { "@angular/*": ["../node_modules/@angular/*"] } 

참조 : 메시지로 link