0
我試圖運行我在CentOS 7 OS,我試圖通過編寫節點install_server.js 安裝我的項目的項目和終端返回我一個錯誤節點JS意外的標記
install_server.js:26
fs.readFile(`${__dirname}/config/config.sql`, (err, data) => {
^
SyntaxError: Unexpected token ILLEGAL
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 Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
而且我發現這個文件的源代碼如下
const cfg = require('./config/config.json');
const knex = require('knex');
const fs = require('fs');
const mysql = require('mysql');
var db = knex({
client: 'mysql',
pool: {
min: 0,
max: 1
},
connection: {
host: cfg.database.db_server,
user: cfg.database.db_user,
password: cfg.database.db_password
}
});
var myCon = mysql.createConnection({
multipleStatements: true,
host: cfg.database.db_server,
user: cfg.database.db_user,
password: cfg.database.db_password
});
fs.readFile(`${__dirname}/config/config.sql`, (err, data) => {
if (err)
throw err;
myCon.query(data.toString(), function(err, results) {
if (err)
throw err;
console.log('complete')
});
});
不能看出來,我能得到一個幫手嗎?
你使用什麼node.js版本?模板字符串被添加到節點v4.0.0 – alexmac
'node -v'指向v 0.10.30,這意味着我需要更新? –
是的,最新的是v8.2.1 – alexmac