2

I try to set up eslint for my project. When i run eslint --init the following error returns:

/usr/lib/node_modules/eslint/lib/cli.js:18 
let fs = require("fs"),
^^^
SyntaxError: Unexpected strict mode reserved word
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/usr/lib/node_modules/eslint/bin/eslint.js:29:11)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)

I have installed eslint with sudo npm install -g eslint

digijap
  • 164
  • 9
  • Eslint doesn't work. I'm not doing anything with my own code right now – digijap Aug 02 '16 at 12:11
  • Sounds like eslint isn't recognising ES6. Is there an option you can configure for ES6 (or if not, try babel-eslint)? – gcampbell Aug 02 '16 at 12:15
  • I had the same suspicion so i thought I had the wrong version of node installed but that is also up to date (v0.15.2). Babel eslint didn't make a difference.. – digijap Aug 02 '16 at 12:29
  • What version does `node -v` show you? `v0.15.2` does not seem to be a valid node version. – t.niese Aug 02 '16 at 12:37
  • Yeah i noticed that too but I installed node by apt-get. Do you think that's the problem? – digijap Aug 02 '16 at 12:38
  • Sorry i didn't remember the version number correctly it is :`$ node -v v0.12.15` – digijap Aug 02 '16 at 12:39
  • 1
    The current versions of node are `4.4.7` and `6.3.1`. Node `0.12.x` is from `2015-02-06` and `v0.12.15` is just a bug fix release. So new language features like `let` are either not available in `0.12.x` or require the usage of `'use strict'` and/or the [`--harmony`](http://stackoverflow.com/questions/15284029) argument. But you really shouldn't use `--harmony` instead you should install a newer version of node using [Installing Node.js via package manager](https://nodejs.org/en/download/package-manager/) – t.niese Aug 02 '16 at 12:42
  • 1
    Thanks! I was updating already after i found that link. That did the trick. – digijap Aug 02 '16 at 12:46

1 Answers1

1

So I installed node by sudo apt-get install node. This installed a version that did not support eslint. After installing NodeJS by running

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install nodejs

After upgrading from 0.12.15 to 4.4.7 eslint worked!

digijap
  • 164
  • 9