2016-11-06 49 views
1

我創建了一個簡單的應用程序,使用sailjs。在運行應用程序它給下面ê錯誤用戶模型的Sailjs錯誤:錯誤:掛鉤(`orm`)未能加載

error: A hook (`orm`) failed to load! 
error: `include-all` attempted to `require(G:\workspare\web\sailsapp\api\models\Users.js)`, but an error occurred:: 
Details:SyntaxError: Unexpected identifier 
    at exports.runInThisContext (vm.js:53:16) 
    at Module._compile (module.js:374:25) 
    at Object.Module._extensions..js (module.js:417:10) 
    at Module.load (module.js:344:32) 
    at Function.Module._load (module.js:301:12) 
    at Module.require (module.js:354:17) 
    at require (internal/module.js:12:17) 

我users.js模型就像

module.exports = { 

    attributes: { 
    id : { 
     type : 'integer', 
     unique : true, 
     primaryKey: true 
    }, 
    userName : { 
     type : 'string' 
     required : true  
    }, 
    email : { 
     type : 'email', 
     required : true, 
     unique : true 
    }, 
    ePassword : { 
     type : 'string' 
    } 
    } 
}; 
  • 賽歐:v0.12.9
  • 節點:v4.2.6

我檢查了其他答案,但它對我沒有用處。任何人都可以告訴我我做錯了什麼/我該如何克服這個錯誤?

回答

2
error: 'include-all' attempted to 'require(G:\workspare\web\sailsapp\api\models\Users.js)', but an error occurred:: 

表示Users.js中有錯誤。

Details:SyntaxError: Unexpected identifier 

一般由語法錯誤,缺少逗號,括號,托架等。在這種情況下引起的,它是一個丟失的逗號。

userName : { 
     type : 'string' , // <--- 
     required : true  
}, 
+0

OMG!我檢查了5-6次,但找不到失蹤的','。我知道你爲什麼發現錯誤。因爲你有鷹眼。 :) –

+0

@AtulArvind - 開始使用像WebStorm這樣的IDE,你不會有這種問題。 –