我正在尝试使用bookshelf-modelbase并在运行服务器时获取SyntaxError:
//model.js
var knex = require('knex')(require('../knexfile').development);
var bookshelf = require('bookshelf')(knex);
var ModelBase = require('bookshelf-modelbase')(bookshelf);
//...
错误:
/node_modules/bookshelf-modelbase/lib/index.js:77
return this.findOne({ [this.prototype.idAttribute]: id }, options)
^
SyntaxError: Unexpected token [
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
有没有人遇到过这个错误?
答案 0 :(得分:0)
您应该尝试使用Node.js v4及更高版本。
答案 1 :(得分:0)
试试这个:
var param = {}
param[this.prototype.idAttribute]=id
return this.findOne(param, options)