nodejs SyntaxError:意外的标记
我正在使用elasticsearch-exporter
从Elasticsearch
导出数据。
该工具最初是一个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。
- ElasticSearch JS客户端search
- 全文search的想法MongoDB&node.js
- 在Elasticsearch中使用nodejs创build索引时出错
- elasticdump:dump以错误结束(get phase)=>错误:连接ECONNREFUSED MY_IP:PORT
- putMapping elasticsearch索引找不到exception
- NodeJs-ElasticSearch批量APIerror handling
- 当字段未定义或从对象丢失时从elasticsearch获取数据
- ElasticSearch _bulk调用导致“套接字挂起”,尽pipe体积小
- 卡夫卡到node.js的Elasticsearch消费