2017-04-17 106 views
4

爲了引入更新的版本,我正在升級以前可用的ng2應用中的Angular CLI(v1.0.0),Angular(v4.0.2)和相關軟件包角材料。與因重大更改幾個其他錯誤戰鬥後,我留下了這樣的構建:Angular 4構建錯誤:遇到的錯誤靜態解析符號值

ERROR in Error encountered resolving symbol values statically. Only initialized variables and constants can be referenced because the value of this variable is needed by the template compiler (position 15:22 in the original .ts file),

resolving symbol ROUTES in /path/node_modules/@angular/router/src/router_config_loader.d.ts,

resolving symbol makeRootProviders in /path/node_modules/ui-router-ng2/lib/uiRouterNgModule.d.ts,

resolving symbol UIRouterModule.forRoot in /path/node_modules/ui-router-ng2/lib/uiRouterNgModule.d.ts,

resolving symbol AppModule in /path/src/app/app.module.ts,

resolving symbol AppModule in /path/src/app/app.module.ts

ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/path/src' @ ./src/main.ts 5:0-74 @ multi ./src/main.ts

我相信,錯誤涉及我UIRouter配置(在app.module.ts),但我真的很不知道:

imports: [ 
    BrowserModule, 
    FormsModule, 
    HttpModule, 
    MaterialModule.forRoot(), 
    FlexLayoutModule, 
    UIRouterModule.forRoot({ 
     states: [ 
      homeState, 
      buttonsState, 
      colorState, 
      fontsState, 
      iconsState, 
      logosState, 
      messagingState, 
      typographyState 
     ], 
     useHash: false 
    }) 
], 

我懷疑第一個問題解決後,第二個錯誤將消失。我試圖創建一個返回UIRouterModule配置的函數,但這沒有幫助。援助感謝。

回答

0

我認爲問題是與一個導入語句。它看起來像你試圖導入ROUTES到您的.ts文件中的一個,如:

import { ROUTES } from '@angular/router/src/router_config_loader';

任何進口應當從@angular/router'@angular/router/src/router_config_loader'。可能發生的是您的IDE自動爲您導入常量,並使用了錯誤的路徑。

我有一個類似的問題,解決this SO answer

相關問題