3

I'm getting this error when running eslint init, It doesnt appear to be triggered by any of my files, rather by its own code. I've seen someone on another site with the same error message. I've tried to uninstall and reinstall and tried an older version to no avail.

oem@Trevor:~/signal-labs-nodejs-coding-challenege$ eslint --init
? How would you like to use ESLint? To check syntax, find problems, and enforce code style
? What type of modules does your project use? JavaScript modules (import/export)
? Which framework does your project use? None of these
? Does your project use TypeScript? No
? Where does your code run? Browser, Node
? How would you like to define a style for your project? Use a popular style guide
? Which style guide do you want to follow? Airbnb: https://github.com/airbnb/javascript
? What format do you want your config file to be in? JavaScript
Checking peerDependencies of eslint-config-airbnb-base@latest
Unexpected token { in JSON at position 139
SyntaxError: Unexpected token { in JSON at position 139
    at JSON.parse (<anonymous>)
    at Object.fetchPeerDependencies (/usr/local/lib/node_modules/eslint/lib/init/npm-utils.js:83:17)
    at getPeerDependencies (/usr/local/lib/node_modules/eslint/lib/init/config-initializer.js:81:27)
    at hasESLintVersionConflict (/usr/local/lib/node_modules/eslint/lib/init/config-initializer.js:388:30)
    at Object.when (/usr/local/lib/node_modules/eslint/lib/init/config-initializer.js:568:83)
    at /usr/local/lib/node_modules/eslint/node_modules/run-async/index.js:25:25
    at new Promise (<anonymous>)
    at /usr/local/lib/node_modules/eslint/node_modules/run-async/index.js:24:19
    at /usr/local/lib/node_modules/eslint/node_modules/inquirer/lib/ui/prompt.js:114:32
    at Observable._subscribe (/usr/local/lib/node_modules/eslint/node_modules/rxjs/internal/observable/defer.js:10:21)
2
  • This github issue may be helpful, have you checked your package.json for syntax errors? Commented Jan 8, 2020 at 13:18
  • @segFault I ran it through a syntax checker and its free of error Commented Jan 8, 2020 at 18:50

3 Answers 3

5

In my case this was caused by having an ancient version of node in my project. Updating the node version fixed it for me.

Sign up to request clarification or add additional context in comments.

Comments

3

The same thing happened to me. The problem was in the .npm folder that did not have the necessary permissions. I ran the command:

sudo chmod -R 777 /home/<user>/.npm

And everything went back to working normally

1 Comment

Did your instructions but still getting the same error. Maybe a restart will fix things but not quite sure. Anyways, permissions are always good to be open for a development environment.
0

There was an issue opened about this, and here's their solution:

sudo npm cache clean --force

The install went smoothly after that.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.