4

eslint --fix option is not working when i run it through npm. Here is my package.json scripts

"scripts":            
{
    "start": "nodemon ./server.js --exec babel-node",          
    "lint": "eslint ./data/* --format html  --output-file ./finalresult.html --fix ; exit 0"
}

when I run it using command npm run lint report is generating but without fixing. But if I am running the same command

eslint ./data/* --format html --output-file ./finalresult.html --fix

from console it is generating report after fix.Why is it so? Am I doing anything wrong? Can Anyone please help me

5
  • 1
    is the version of eslint in your node modules same as it is globally? Or are you sure the errors are fix-able? Commented Jul 27, 2017 at 11:23
  • 1
    Hi @tbking you were spot on. In my package .json i changed the command to /usr/local/bin/eslint ./data/* --format html --output-file ./finalresult.html --fix and now it works perfectly fine with npm run lint. Thanks a lot Commented Jul 27, 2017 at 11:32
  • The reason was version mismatch Commented Jul 27, 2017 at 11:33
  • Cool. It happens to all of us. I'll just write it as an answer so that other people can find it easily Commented Jul 27, 2017 at 11:44
  • Anyone else running into this may also want to check out stackoverflow.com/a/74817581/5602521 which ended up being my problem Commented Apr 13, 2023 at 16:23

1 Answer 1

2

Check the version of the eslint in your local and global node_modules.

When we run from command line, the global eslint executes while npm uses the one in local node_modules.

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

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.