nodejs SyntaxError:意外的标记

我正在使用elasticsearch-exporterElasticsearch导出数据。

该工具最初是一个nodejs应用程序。

当我尝试使用下面的命令node exporter.js使工具列出所有可用的选项时,它会崩溃,出现以下exception

 /home/me/storage/Elasticsearch-Exporter/log.js:54 exports.error = (...args) => !capture("ERROR", args) && console.log(timestamp() + util.format(...args).red); ^^^ SyntaxError: Unexpected token ... at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:374:25) at Object.Module._extensions..js (module.js:417:10) at Module.load (module.js:344:32) at Function.Module._load (module.js:301:12) at Module.require (module.js:354:17) at require (internal/module.js:12:17) at Object.<anonymous> (/home/anas/storage/Elasticsearch-Exporter/exporter.js:9:11) at Module._compile (module.js:410:26) at Object.Module._extensions..js (module.js:417:10) 

这里是抛出exception的行

 exports.error = (...args) => !capture("ERROR", args) && console.log(timestamp() + util.format(...args).red); 

我认为这个错误与nodejs的不同版本有关,但我不确定。

这是node --version命令v4.2.6的输出

这是npm --version命令3.10.6的输出

是的,的确, ...被称为传播运算符 ,并且仅在Node.js 6之后才可用

elasticsearch-exporter项目在package.json文件中声明它只能在节点版本> 6的情况下工作

因此,由于您正在运行Node.js 4.2.6,因此您需要升级Node.js安装或者fork elasticsearch-exporter项目并修改它以使用Node.js 4.2.6。