gpt4 book ai didi

Angular 4 构建错误 : Error encountered resolving symbol values statically

转载 作者:太空狗 更新时间:2023-10-29 18:01:51 25 4
gpt4 key购买 nike

我正在升级 Angular CLI (v1.0.0)、Angular (v4.0.2) 和以前工作的 ng2 应用程序中的相关包,以便引入更新版本的 Angular Material。由于重大更改而与其他几个错误作斗争后,我在构建时留下了这个:

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 配置的函数,但这没有帮助。协助表示赞赏。

最佳答案

我认为问题出在导入语句上。看起来您正在尝试将 ROUTES 导入到您的其中一个 .ts 文件中,例如:

从'@angular/router/src/router_config_loader'导入{ROUTES};

任何导入都应该来自 @angular/router 而不是 '@angular/router/src/router_config_loader'。可能发生的情况是您的 IDE 自动为您导入了常量,并且它使用了错误的路径。

this SO answer 解决了我的类似问题.

关于Angular 4 构建错误 : Error encountered resolving symbol values statically,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43455052/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com