功能箭头出错意外的令牌>

时间:2016-05-16 19:14:56

标签: javascript node.js ecmascript-6

我不明白为什么我的控制台在功能箭头

中显示错误

记录错误

/home/david/js/script.js:3
var file = fs.readFile('file.txt', (err, data) => {
                                                ^
SyntaxError: Unexpected token >
    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:902:3

我的功能

var fs = require("fs");

var file = fs.readFile('file.txt', (err, data) => {
  if (err) throw err;
        console.log(data);
});

解决方案reinstall node

0 个答案:

没有答案
相关问题