node.js - 用户模型上的 Sails Js 错误 : error: A hook (`orm` ) failed to load

标签 node.js express sails.js

我使用sailjs创建了一个简单的应用程序。运行应用程序时出现以下错误

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'
    }
  }
};
  • sails :v0.12.9
  • Node :v4.2.6

我已经检查了其他答案,但它对我没有用。任何人都可以告诉我我做错了什么/我该如何克服这个错误?

最佳答案

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     
},

关于node.js - 用户模型上的 Sails Js 错误 : error: A hook (`orm` ) failed to load,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40450928/

相关文章:

javascript - 如何将node.js服务器应用程序编译为可执行文件?

node.js - Sails 在错误的目录中查找

node.js - NodeJS exec/spawn stdout 在 8192 个字符处切断流

node.js - 在 Azure 上部署 MEAN+Webpack

javascript - Facebook 和 google 如何随机化 html 选择器 id 和类名?

json - 在 Freebase 中获取每道菜页面的菜肴列表和详细信息?

javascript - 无法访问此函数内的参数

javascript - Node/Express Rest API - 如何从 mssql 抛出错误

javascript - 返回对象的 ID 为零(在数据库中创建记录)

javascript - sailsjs 其中多对多关系包含