2017-05-16 36 views
0

我使用的離子,並出現以下錯誤:離子:錯誤:模塊構建失敗:錯誤:ENOENT:沒有這樣的文件或目錄

Runtime Error Uncaught (in promise): Error: Module build failed: Error: ENOENT: no such file or directory, open '/Users/richardmarais/Development/ionic/theWhoZoo/src/pages/model/ratingModel.js'

的錯誤是這行代碼的結果:

this.ratingModel = new RatingModel(); 

當我刪除這一行時,我沒有得到錯誤。

ratingModel.ts

import { Injectable } from "@angular/core"; 
import { PersonModel } from './personModel'; 
import { JobModel } from './jobModel'; 

@Injectable() 
export class RatingModel { 
     public id: number = null; 
     public job: JobModel = null; 
     public review: string = null; 
     public rating: number = null; 
     public reviewDate: number = null; 
     public time: string = null; 
     public person: PersonModel = null; 
     public anonymous: number = null; 

     constructor() { 

     } 
} 

閱讀其他論壇,人們越來越此錯誤是由於情況下,他們的進口量不匹配,但我已經檢查我的,他們這樣做匹配。

import { RatingModel } from '../model/ratingModel'; 

不過,我已經發現了一些奇怪的我的IDE(Visual Studio代碼):

enter image description here

正如你可以看到,在搜索結果中,有兩個文件爲對象, ratingModel.tsRatingModel.ts。但是,當我檢查的實際文件系統,只有在文件中,ratingModel.ts

enter image description here

問題

有誰知道什麼,以及如何解決是什麼樣子可能是這裏的錯誤或故障?

感謝

更多信息:

global packages: 

    @ionic/cli-utils : 1.0.0 
    Cordova CLI  : 6.4.0 
    Ionic CLI  : 3.0.0 

local packages: 

    @ionic/app-scripts    : 1.3.0 
    @ionic/cli-plugin-cordova  : 1.0.0 
    @ionic/cli-plugin-ionic-angular : 1.0.0 
    Ionic Framework     : ionic-angular 3.2.1 

System: 

    Node  : v7.10.0 
    OS   : macOS Sierra 
    Xcode  : Xcode 8.3.2 Build version 8E2002 
    ios-deploy : not installed 
    ios-sim : not installed 

回答

1

道歉,是我不好。我剛剛發現另一個文件,導入與不正確的大小寫的對象。它看起來好像沒有問題,並且在我的代碼中有一個錯誤。

import { RatingModel } from '../model/RatingModel'; 
0

當您的組件無法在app.module設置中找到時發生此錯誤。 按照這個步驟來解決問題:

  1. 右擊你的網頁瀏覽器,並選擇檢查(在這種情況下,我使用的是Chrome)
  2. 源標籤導航到localhost:8100(默認端口運行離子)
  3. 路由到src - >頁面並打開對應頁面(在本例中爲'model')
  4. .ts文件和路徑的名稱必須與應用中添加的導入路徑的名稱和路徑相同。 module.ts

    在這種情況下不存在model/ratingModel.ts

    注意: 路徑是區分大小寫的(也許.ts文件RatingModel)
相關問題