topic description
an error occurred while running NODE INDEX.JS
c:nodejsbjlsvrindex.js:65
socket.on("msg",async function(msg){
^^^^^
SyntaxError: missing) after argument list
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
sources of topics and their own ideas
what is this problem? excuse me, I"m a beginner. I have a program on hand. Learn to configure access, please help me, and ask me what else I need to change if I am running on a WIN2008 R2 64-bit system.
related codes
/ / Please paste the code text below (do not replace the code with pictures)
/ / configuration parameters =
/ / webSocket port
var ioPort = 8787;
global.bf = false;
process = require ("process");
if (process.argv [2]) {
global.bf = true;
ioPort = 8788;
}
/ / = introduce extensions =
/ / socket.io
var io = require ("socket.io") (ioPort);
console.log ("start up, listen port:" + ioPort);
/ / Global database
/ / Database connection
var lsql = require ("lcg-sql");
/ / if it is a test environment
if (process.platform = = "win32") {
if(true){
global.db = new lsql({
host:"127.0.0.1", //
user:"root", //MySQL
password:"", //MySQL
port:3306, //
charset:"UTF8_GENERAL_CI", //
database:"bjl", //
timezone:"+8:00" //
});
}else{
global.db = new lsql({
host:"127.0.0.1", //
user:"bjl", //MySQL
password:"lcgxxx", //MySQL
port:3306, //
charset:"UTF8_GENERAL_CI", //
database:"bjl", //
timezone:"+8:00" //
});
}
} else {
console.log(":linux");
//
global.db = new lsql({
host:"127.0.0.2", //
user:"bjl", //MySQL
password:"lcgxxx", //MySQL
port:3306, //
charset:"UTF8_GENERAL_CI", //
database:"bjl", //
timezone:"+8:00" //
});
}
/ / = socket.io Distribution =
/ / Connect to the object
io.on ("connect",function (socket) {
//
socket.on("msg",async function(msg){
//action
var type = msg.type.split(".");
var action = new (require("./action/"+type[0]+".js").proxy)(socket,msg);
if(action[type[1]])
var re = await action[type[1]]();
msg.data = re;
socket.emit("msg",msg);
});
});
what result do you expect? What is the error message actually seen?
problem description
the environmental background of the problems and what methods you have tried
related codes
/ / Please paste the code text below (do not replace the code with pictures)