Add `jshint` worker into `scripts` for package.json

710 views Asked by At

Dear stackoverflowers.

I have decided to include jshint into my project to helps me detect errors and potential problems in my JavaScript code. I have installed it at the project's root and I'm able to run next code from the console:

jshint --config .jshintrc ./app/

It returns me several notifications.

Then I've decided to create a special section inside my package.json scripts section. It looks like that:

  "scripts": {
    "jshint": "jshint --config .jshintrc ./app/"
  }

And when I try to run

npm run jshint

It returns me an exception...

enter image description here

1

There are 1 answers

0
Maxim On BEST ANSWER

please check it out https://github.com/npm/npm/issues/6124, you can prevent this error if you set your script with following || true like in code snippet bellow

{
 "scripts": {
   "test": "jshint || true"
 }
}

in this case your script will finish with exit code = 0, and npm will no throw an error