-1
試圖通過這段代碼連接到蒙戈DB數據庫:終端語法錯誤:之後參數列表丟失)
const mongoose = require('mongoose');
//Connect to mongodb
mongoose.connect('mongodb://localhost/testaroo');
mongoose.connection.once('open'.function(){
console.log('Connection has been made');
}).on('error', function(error){
console.log('Connection Error:', error);
});
但是,當我試圖通過
終端連接到它MG-MC-iMacs-iMac:~ MG-MC-TJUBA$ node mongodb/PingPongDB/connection.js
它給我這個錯誤:
/Users/MG-MC-TJUBA/mongodb/PingPongDB/connection.js:6
mongoose.connection.once('open'.function(){
^
SyntaxError: missing) after argument list
at createScript (vm.js:74:10)
at Object.runInThisContext (vm.js:116:10)
at Module._compile (module.js:533:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:575:3
從我看到它說我錯過了一個')'已經存在和需要。
使用像jsHint或JSLint的或其他棉短絨在那裏的一個工具... – epascarello
更換點(。)用逗號(,) –