Node.js Nodejs语法错误:意外标记{

Node.js Nodejs语法错误:意外标记{,node.js,express,Node.js,Express,我正在遵循一个教程,我不能否认这个错误,因为我已经仔细检查过了,很确定我的新保姆又开始攻击了 SyntaxError: Unexpected token { at new Script (vm.js:51:7) at createScript (vm.js:138:10) at Object.runInThisContext (vm.js:199:10) at Module._compile (module.js:624:28) at Object.Mod

我正在遵循一个教程,我不能否认这个错误,因为我已经仔细检查过了,很确定我的新保姆又开始攻击了

SyntaxError: Unexpected token {
    at new Script (vm.js:51:7)
    at createScript (vm.js:138:10)
    at Object.runInThisContext (vm.js:199:10)
    at Module._compile (module.js:624:28)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
[nodemon] app crashed - waiting for file changes before starting.


用于声明函数的表达式无效


为了声明函数,应该使用
this.getnoticeas=function(…)

因此,完整的代码应该如下所示:

this.getNoticias = function(connection, callback){
    connection.query('select * from noticias', callback);
}

this.thing(…){…}
无效。您试图做什么?
this.getNotifias=function
this.getNoticias = function(connection, callback){
    connection.query('select * from noticias', callback);
}