When running eslint with npm script, npm throws error.
See original GitHub issueTell us about your environment Windows_NT 10.0.14393 ESLint is installed as devDependency
- ESLint Version: v3.13.1
- Node Version: v6.9.1
- npm Version: v3.10.8
What parser (default, Babel-ESLint, etc.) are you using? Default
Please show your full configuration:
Dead simple .eslintrc.js
in the root folder:
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 2017,
sourceType: 'script',
},
rules: {
'no-unused-vars': 2,
'no-console': 1
}
}
What did you do? Please include the actual source code causing the issue. Dead simple test file in the root folder to emit both error and warning.
const a = console.log('');
What did you expect to happen? I should see standard ESLint output (lint error, warning, etc.)
What actually happened? Please include the actual, raw output from ESLint.
- When I run eslint directly from CL with
node_modules\.bin\eslint tst.js
I get expected output:
λ node_modules\.bin\eslint tst.js
C:\OpenServer\domains\EXAMPLES\webpack-react-redux-starter\tst.js
1:9 error 'a' is assigned a value but never used no-unused-vars
1:13 warning Unexpected console statement no-console
✖ 2 problems (1 error, 1 warning)
- But when I run simple npm script…
"scripts": {
"lint": "eslint tst.js"
}
… I get standard ESLint at first and then npm error:
λ npm run lint
> webpack-react-redux-starter@0.1.0 lint C:\OpenServer\domains\EXAMPLES\webpack-react-redux-starter
> eslint tst.js
C:\OpenServer\domains\EXAMPLES\webpack-react-redux-starter\tst.js
1:9 error 'a' is assigned a value but never used no-unused-vars
1:13 warning Unexpected console statement no-console
✖ 2 problems (1 error, 1 warning)
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "lint"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! webpack-react-redux-starter@0.1.0 lint: `eslint tst.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webpack-react-redux-starter@0.1.0 lint script 'eslint tst.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the webpack-react-redux-starter package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! eslint tst.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs webpack-react-redux-starter
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls webpack-react-redux-starter
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\OpenServer\domains\EXAMPLES\webpack-react-redux-starter\npm-debug.log
Output in debug mode with "lint": "eslint tst.js --debug"
:
λ npm run lint
> webpack-react-redux-starter@0.1.0 lint C:\OpenServer\domains\EXAMPLES\webpack-react-redux-starter
> eslint tst.js --debug
eslint:cli Running on files +0ms
eslint:glob-util Creating list of files to process. +31ms
eslint:ignored-paths Looking for ignore file in C:\OpenServer\domains\EXAMPLES\webpack-react-redux-starter +0ms
eslint:ignored-paths Could not find ignore file in cwd +0ms
eslint:cli-engine Processing C:\OpenServer\domains\EXAMPLES\webpack-react-redux-starter\tst.js +0ms
eslint:cli-engine Linting C:\OpenServer\domains\EXAMPLES\webpack-react-redux-starter\tst.js +0ms
eslint:config Constructing config for C:\OpenServer\domains\EXAMPLES\webpack-react-redux-starter\tst.js +0ms
eslint:config Using .eslintrc and package.json files +0ms
eslint:config Loading C:\OpenServer\domains\EXAMPLES\webpack-react-redux-starter\.eslintrc.js +0ms
eslint:config-file Loading JS config file: C:\OpenServer\domains\EXAMPLES\webpack-react-redux-starter\.eslintrc.js +0ms
eslint:config Using C:\OpenServer\domains\EXAMPLES\webpack-react-redux-starter\.eslintrc.js +16ms
eslint:config Merging command line environment settings +0ms
eslint:config-ops Apply environment settings to config +0ms
eslint:cli-engine Linting complete in: 54ms +38ms
C:\OpenServer\domains\EXAMPLES\webpack-react-redux-starter\tst.js
1:7 error 'a' is assigned a value but never used no-unused-vars
1:11 warning Unexpected console statement no-console
✖ 2 problems (1 error, 1 warning)
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "lint"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! webpack-react-redux-starter@0.1.0 lint: `eslint tst.js --debug`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webpack-react-redux-starter@0.1.0 lint script 'eslint tst.js --debug'.npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the webpack-react-redux-starter package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! eslint tst.js --debug
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs webpack-react-redux-starter
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls webpack-react-redux-starter
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\OpenServer\domains\EXAMPLES\webpack-react-redux-starter\npm-debug.log
- If I change my tst.js code so it triggers only lint warning I get expected output (no npm error):
λ npm run lint
> webpack-react-redux-starter@0.1.0 lint C:\OpenServer\domains\EXAMPLES\webpack-react-redux-starter
> eslint tst.js
C:\OpenServer\domains\EXAMPLES\webpack-react-redux-starter\tst.js
1:1 warning Unexpected console statement no-console
✖ 1 problem (0 errors, 1 warning)
It’s not a big problem, when I just want to lint some files.
But it becomes a problem when I chain my lint
task with other tasks, cause all subsequent tasks don’t run after error occurs.
P.S. There’s closed issue #7402 related to the same problem. I wrote there too. But since get no responce file a new one.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:11 (4 by maintainers)
Top GitHub Comments
npm run lint -s
displays the linter output and silences the npm output.You get the npm error because when your code has linting errors in it, ESLint returns with a non-zero exit code indicating a problem running the script.