Ionic 2完全坏了,没有编译

时间:2016-11-01 14:10:08

标签: angular ionic2

应用程序工作正常,但在移动到新计算机后

Ionic 2应用程序在新计算机中安装后完全破坏并丢失以下错误,我使用的是最新的节点7.0

sudo npm install -g ionic cordova
sudo npm install -g angular2-cli 
npm update

我在执行

之前运行的上述命令
ionic serve
    [21:57:16]  ionic-app-scripts 0.0.39 
    [21:57:16]  watch started ... 
    [21:57:16]  build dev started ... 
    [21:57:16]  clean started ... 
    [21:57:16]  clean finished in 3 ms 
    [21:57:16]  copy started ... 
    [21:57:16]  transpile started ... 
    [21:57:17]  lint started ... 
    [21:57:19]  lint finished in 2.47 s 
    [21:57:20]  typescript: node_modules/ionic-angular/components/checkbox/checkbox.d.ts, line: 8 
                Cannot find name 'ControlValueAccessor'. 

       L7:  export declare const CHECKBOX_VALUE_ACCESSOR: any;
       L8:  export declare class Checkbox extends Ion implements AfterContentInit, ControlValueAccessor, OnDestroy {
       L9:      private _form;

[21:57:20]  typescript: node_modules/ionic-angular/components/datetime/datetime.d.ts, line: 10 
            Cannot find name 'ControlValueAccessor'. 

       L9:  export declare const DATETIME_VALUE_ACCESSOR: any;
      L10:  export declare class DateTime extends Ion implements AfterContentInit, ControlValueAccessor, OnDestroy {
      L11:      private _form;

[21:57:20]  typescript: node_modules/ionic-angular/components/input/input-base.d.ts, line: 35 
            Cannot find name 'NgControl'. 

      L34:  _native: NativeInput;
      L35:  inputControl: NgControl;
      L36:  constructor(config: Config, _form: Form, _item: Item, _app: App, _platform: Platform, elementRef: ElementRef, renderer: Renderer, _scrollView: Content, nav: NavController, ngControl: NgControl);

[21:57:20]  typescript: node_modules/ionic-angular/components/input/input-base.d.ts, line: 36 
            Cannot find name 'NgControl'. 

      L35:  inputControl: NgControl;
      L36:  elementRef: ElementRef, renderer: Renderer, _scrollView: Content, nav: NavController, ngControl: NgControl);
      L37:  scrollMove(ev: UIEvent): void;
[21:57:20]  typescript: node_modules/ionic-angular/components/input/input-base.d.ts, line: 39 

            Cannot find name 'NgControl'. 

      L38:  setItemInputControlCss(): void;
      L39:  setControlCss(element: any, control: NgControl): void;
      L40:  setValue(val: any): void;

[21:57:20]  typescript: node_modules/ionic-angular/components/input/input.d.ts, line: 13 
            Cannot find name 'NgControl'. 

      L12:  export declare class TextInput extends InputBase {
      L13:   elementRef: ElementRef, renderer: Renderer, scrollView: Content, nav: NavController, ngControl: NgControl);
      L14:      _clearInput: boolean;

[21:57:20]  typescript: node_modules/ionic-angular/components/input/input.d.ts, line: 33 
            Cannot find name 'NgControl'. 

      L32:  export declare class TextArea extends InputBase {
      L33:   elementRef: ElementRef, renderer: Renderer, scrollView: Content, nav: NavController, ngControl: NgControl);
      L34:      placeholder: string;

[21:57:20]  typescript: node_modules/ionic-angular/components/input/native-input.d.ts, line: 7 
            Cannot find name 'NgControl'. 

       L6:  _renderer: Renderer;
       L7:  ngControl: NgControl;
       L8:  _relocated: boolean;

[21:57:20]  typescript: node_modules/ionic-angular/components/input/native-input.d.ts, line: 14 
            Cannot find name 'NgControl'. 

      L13:  valueChange: EventEmitter<string>;
      L14:  constructor(_elementRef: ElementRef, _renderer: Renderer, config: Config, ngControl: NgControl);
      L15:  _change(ev: any): void;

[21:57:20]  typescript: node_modules/ionic-angular/components/picker/picker-component.d.ts, line: 31 
[21:57:20]  typescript: node_modules/ionic-angular/components/range/range.d.ts, line: 25 
            Cannot find name 'DomSanitizer'. 

      L30:  ionChange: EventEmitter<any>;
      L31:  constructor(config: Config, elementRef: ElementRef, _sanitizer: DomSanitizer, _haptic: Haptic);
      L32:  ngAfterViewInit(): void;

            Cannot find name 'ControlValueAccessor'. 

      L25:  export declare class Range extends Ion implements AfterViewInit, ControlValueAccessor, OnDestroy {
      L26:      private _form;
[21:57:20]  typescript: node_modules/ionic-angular/components/searchbar/searchbar.d.ts, line: 33 

            Cannot find name 'NgControl'. 

      L32:  _sbHasFocus: boolean;
      L33:  constructor(config: Config, elementRef: ElementRef, renderer: Renderer, ngControl: NgControl);
      L34:  _searchbarInput: ElementRef;

[21:57:20]  typescript: node_modules/ionic-angular/components/segment/segment.d.ts, line: 25 
            Cannot find name 'NgControl'. 

      L24:  _buttons: QueryList<SegmentButton>;
      L25:  constructor(config: Config, elementRef: ElementRef, renderer: Renderer, ngControl: NgControl);
      L26:  disabled: boolean;

[21:57:21]  typescript: node_modules/ionic-angular/components/select/select.d.ts, line: 11 
            Cannot find name 'ControlValueAccessor'. 

      L10:  export declare const SELECT_VALUE_ACCESSOR: any;
      L11:  export declare class Select extends Ion implements AfterContentInit, ControlValueAccessor, OnDestroy {
      L12:      private _app;

[21:57:21]  typescript: node_modules/ionic-angular/components/toggle/toggle.d.ts, line: 10 
            Cannot find name 'ControlValueAccessor'. 

       L9:  export declare const TOGGLE_VALUE_ACCESSOR: any;
      L10:  export declare class Toggle extends Ion implements AfterContentInit, ControlValueAccessor, OnDestroy {
      L11:      _form: Form;
[21:57:21]  typescript: node_modules/ionic-angular/module.d.ts, line: 17 

            Cannot find name 'PlatformLocation'. 

      L17:  re function provideLocationStrategy(platformLocationStrategy: PlatformLocation, baseHref: string, config: Co
      L18:  export declare function provideUserAgent(): string;

[21:57:21]  typescript: node_modules/ionic-angular/module.d.ts, line: 17 
            Cannot find name 'HashLocationStrategy'. 

      L17:  nStrategy: PlatformLocation, baseHref: string, config: Config): HashLocationStrategy | PathLocationStrategy;
      L18:  export declare function provideUserAgent(): string;
[21:57:21]  typescript: node_modules/ionic-angular/module.d.ts, line: 17 

            Cannot find name 'PathLocationStrategy'. 

      L17:  nStrategy: PlatformLocation, baseHref: string, config: Config): HashLocationStrategy | PathLocationStrategy;
      L18:  export declare function provideUserAgent(): string;

[21:57:21]  typescript: src/services/dataService.ts, line: 14 
            Cannot find name 'Http'. 

      L13:  export class DataService {
      L14:    constructor(private http: Http) {}

[21:57:21]  typescript: src/services/dataService.ts, line: 52 
            Cannot find name 'Response'. 

      L52:  private extractData(res: Response) {
      L53:    let body = res.json();

[21:57:21]  typescript: src/shared/htmlsafe.pipe.ts, line: 7 
            Cannot find name 'DomSanitizer'. 

       L6:  export class HtmlSafePipe implements PipeTransform {
       L7:  constructor(public sanitizer:DomSanitizer){}
       L8:    transform(input:string):SafeHtml {

[21:57:21]  typescript: src/shared/htmlsafe.pipe.ts, line: 8 
            Cannot find name 'SafeHtml'. 

       L7:  constructor(public sanitizer:DomSanitizer){}
       L8:    transform(input:string):SafeHtml {
       L9:      return this.sanitizer.bypassSecurityTrustHtml(input); 

    [21:57:21]  transpile failed 

3 个答案:

答案 0 :(得分:1)

这是依赖性问题,尝试执行:

rm -r node_modules

然后

npm install

答案 1 :(得分:1)

现在问题已解决:对某些问题可能有用:package.json

中缺少以下条目
"dependencies": {
    "@angular/common": "2.0.0",
    "@angular/compiler": "2.0.0",
    "@angular/compiler-cli": "0.6.2",
    "@angular/core": "2.0.0",
    "@angular/forms": "2.0.0",
    "@angular/http": "2.0.0",
    "@angular/platform-browser": "2.0.0",
    "@angular/platform-browser-dynamic": "2.0.0",
    "@angular/platform-server": "2.0.0",
    "@ionic/storage": "1.1.6",
    "ionic-angular": "2.0.0-rc.1",
    "ionic-native": "2.2.3",
    "ionicons": "3.0.0",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "0.6.21"
  },
  "devDependencies": {
    "@ionic/app-scripts": "0.0.38",
    "typescript": "2.0.6"
  },

答案 2 :(得分:0)

尝试如下安装@angular/forms

npm install @angular/forms