Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm throwing an error at the end of the eslint report

I have an issue when running eslint on my typescript project. I have the following package.json, where I wrote a script to run eslint:

{
  "name": "ts-tutorial",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "transpile": "tsc",
    "lint": "eslint src --ext ts"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "eslint": "^4.19.1",
    "eslint-config-standard": "^11.0.0",
    "eslint-plugin-import": "^2.9.0",
    "eslint-plugin-node": "^6.0.1",
    "eslint-plugin-promise": "^3.7.0",
    "eslint-plugin-standard": "^3.0.1",
    "typescript": "^2.7.2",
    "typescript-eslint-parser": "^14.0.0"
  }
}

So now, when I run npm run ling I get the right output, with all the error that my code has, that need to be linted. But at the end of the list, I see an npm error:

✖ 7 problems (7 errors, 0 warnings)
  6 errors, 0 warnings potentially fixable with the `--fix` option.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] lint: `eslint src --ext ts`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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!     /home/dbugger/.npm/_logs/2018-03-26T16_44_57_459Z-debug.log

What is causing this error? I have read the log file, but I cannot understand what is the problem from reading it.

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'lint' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle [email protected]~prelint: [email protected]
6 info lifecycle [email protected]~lint: [email protected]
7 verbose lifecycle [email protected]~lint: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~lint: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:/home/dbugger/projects/exercises/ts-tutorial/node_modules/.bin:/home/dbugger/.rbenv/plugins/ruby-build/bin:/home/dbugger/.rbenv/shims:/home/dbugger/.rbenv/bin:/home/dbugger/npm-global/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle [email protected]~lint: CWD: /home/dbugger/projects/exercises/ts-tutorial
10 silly lifecycle [email protected]~lint: Args: [ '-c', 'eslint src --ext ts' ]
11 silly lifecycle [email protected]~lint: Returned: code: 1  signal: null
12 info lifecycle [email protected]~lint: Failed to exec lint script
13 verbose stack Error: [email protected] lint: `eslint src --ext ts`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:280:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid [email protected]
15 verbose cwd /home/dbugger/projects/exercises/ts-tutorial
16 verbose Linux 4.13.0-37-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "lint"
18 verbose node v8.9.3
19 verbose npm  v5.5.1
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] lint: `eslint src --ext ts`
22 error Exit status 1
23 error Failed at the [email protected] lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
like image 987
Enrique Moreno Tent Avatar asked Mar 26 '18 16:03

Enrique Moreno Tent


People also ask

How do I fix ESLint error?

If you have the ESLint extension installed you can use CTRL+SHIFT+P to open the Command Palette. Then search for ESLint: Fix all auto-fixable Problems and press ENTER (or RETURN ). You are free from counting indentation and checking for quotation marks and semicolons!

How do I check for ESLint errors?

It fixes all issues for me. To check the errors first: npx eslint . npx eslint --fix .

How do I run ESLint in node JS?

First, initialize a Node. js project. Now, install the eslint npm package. In order to initialize an ESLint configuration, let us run the command.


1 Answers

This is expected. By design, eslint exits with status 1 if there are any linting errors. npm interprets this as an error, and it's telling you so.

If you want to suppress the bad exit code, you can use one of the workarounds suggested here: https://github.com/eslint/eslint/issues/7933.

like image 184
ethan.roday Avatar answered Dec 12 '22 22:12

ethan.roday