question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When running eslint with npm script, npm throws error.

See original GitHub issue

Tell 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.

  1. 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)
  1. 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
  1. 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:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

31reactions
crcdngcommented, Mar 23, 2017

npm run lint -s displays the linter output and silences the npm output.

3reactions
BYKcommented, Jan 17, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to run eslint --fix from npm script - Stack Overflow
I did try "lint-fix": "eslint --fix --ext .js,.vue src test/unit/specs test/e2e/specs" but it is throwing my errors but not fixing them. What ...
Read more >
NPM — How to Run ESLint --fix From npm Script - Future Studio
This tutorial shows you how to run ESLint with the --fix flag from an NPM script. NPM Quick Tips Series Overview. NPM Quick...
Read more >
Command Line Interface - ESLint - Pluggable JavaScript Linter
This option throws an error when code is piped to ESLint. This option has no effect on code that uses a processor, unless...
Read more >
ESLint Error at npm start --open - Material Design for Bootstrap
Hello, im getting the following error when im afther unzipping the folder and running npm start --open. " ERROR Failed to compile with...
Read more >
NPM local server won't start. I am getting an error with ESLint
Clean your node cache. npm cache clean --force · Remove your node_modules folder. rm -rf node_modules/ · Fresh install. npm install · Run...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found