从角度2升级到4

时间:2017-09-06 08:03:35

标签: angular angular-cli

将我的应用从角度2更新为角度4

时出现以下错误
  

ERROR in Error遇到静态解析符号值。只要   可以引用初始化变量和常量,因为   模板编译器需要此变量的值(位置   663:22在原始.ts文件中),解析符号组件   d:/mdp/mdp-internaltools-app/node_modules/@angular/core/src/metadata/directives.d.ts,   解析中的符号ProcessingComponent   d:/mdp/mdp-internaltools-app/src/app/processing-component/processing-component.component.ts,   解析中的符号ProcessingComponent   d:/mdp/mdp-internaltools-app/src/app/processing-component/processing-component.component.ts

ERROR in ./src/index.ts
Module not found: Error: Can't resolve './../aot/src/app/app.module.ngfactory' in
     

'd:\ MDP \ MDP-internaltools应用内\ src' 中       @ ./src/index.ts 3:0-75       @ multi ./src/index

我很久以来无法识别错误,其他人也遇到了同样的错误。

处理-component.ts

import {Component} from '@angular/core/src/metadata/directives';

@Component({
    selector: 'mdp-processing',
    template: require('./processing-component.component.html')
})
export class ProcessingComponent {

}

processing.component.html

 <!-- Processing Tab Navigation -->
    <mdp-processing-navbar></mdp-processing-navbar>

    <!-- Processing Tab Main section/tabs -->
    <router-outlet></router-outlet>

1 个答案:

答案 0 :(得分:0)

首先,您的模板中不需要require

其次,确保您拥有所有项目依赖项的所有正确版本。对我来说,从A2升级到A4的最简单方法是使用Angular CLI。生成一个新项目,比如Hello-CLI。然后将Hello-CLI package.json中的依赖项和devDependencies部分复制到A2项目的package.json中,然后运行npm install。

第三,确保你的引导代码(main.ts)位于app模块的单独文件中。

相关问题