I am new to JS and I am trying to learn about linting. So, I am following a tutorial where we set the lint
stage in the package.json
file.
It looks like this: "lint": "./node_modules/.bin/eslint ."
So in the terminal, when I run ./node_modules/.bin/eslint .
it is reporting back all the errors and warnings which is nice, as expected.
/Users/me/dev/webapps/templates/sample_node_project/index.js
1:1 error Expected 1 empty line after require statement not followed by another require import/newline-after-import
1:35 error Missing semicolon semi
5:27 error Missing semicolon semi
9:3 warning Unexpected console statement no-console
9:53 error Missing semicolon semi
✖ 5 problems (4 errors, 1 warning)
4 errors and 0 warnings potentially fixable with the `--fix` option.
But when I run npm run lint
, I am getting this:
/Users/me/dev/webapps/templates/sample_node_project/index.js
1:1 error Expected 1 empty line after require statement not followed by another require import/newline-after-import
1:35 error Missing semicolon semi
5:27 error Missing semicolon semi
9:3 warning Unexpected console statement no-console
9:53 error Missing semicolon semi
✖ 5 problems (4 errors, 1 warning)
4 errors and 0 warnings potentially fixable with the `--fix` option.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sample_node_project@1.0.0 lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sample_node_project@1.0.0 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/me/.npm/_logs/2018-10-25T23_15_56_180Z-debug.log
So this throws an extra block of errors, which made me think that my node
and npm
is corrupt. Also, in the tutorial, the instructor is running yarn lint
and he seems to be getting a lot less of that additional error block.
Is that normal?
npm run lint -s
will suppress the NPM error that you are seeing. ESLint gives you a non-zero exit code because of the lint errors. NPM is basically saying that it can't run correctly because of the linting errors. So yes, it's normal.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.