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.

Using a local eslint makes node load a shell script

See original GitHub issue

Running windows 10, sublime text 3, ESLint-Formatter 2.1.1.

I just created an empty project and installed eslint locally. I have auto-format turned on on ESLint-Formatter config.

Seemingly 1 in 5 saves, eslint tries to load from the local eslint, and the other 4 it uses global. I assume this is probably #17 causing it to not always find the local eslint.

Whenever it uses the global eslint, it loads node with %APPDATA%/npm/node_modules/eslint/bin/eslint which is a Javascript file, and works great. However…

Whenever it uses the local eslint, it loads node with node_modules/.bin/eslint which is a shell file, and causes this to pop up as an error message:

Unexpected error(<class 'Exception'>): Error: <project>\node_modules\.bin\eslint:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^
SyntaxError: missing ) after argument list
    at Object.exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:513:28)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.runMain (module.js:575:10)
    at run (node.js:348:7)
    at startup (node.js:140:9)
    at node.js:463:3

I’d suggest looking for node_modules/eslint/bin/eslint for local installations instead.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Dinnerbonecommented, Aug 3, 2016

For me, on windows, it’s a shell script:

#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
  "$basedir/node"  "$basedir/../eslint/bin/eslint.js" "$@"
  ret=$?
else 
  node  "$basedir/../eslint/bin/eslint.js" "$@"
  ret=$?
fi
exit $ret
0reactions
TheSaviorcommented, Aug 3, 2016

Yeah, that seems like a reasonable approach, thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Started with ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
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 >
How to configure package.json to run eslint script
I have setup eslint using tern in my eclipse oxygen. It is linting all the files, I have to set it up to...
Read more >
How To Lint and Format Code with ESLint in Visual Studio Code
In this case, eslint is a package that is only needed when you are actively working on and making changes to your project....
Read more >
ESLint | IntelliJ IDEA Documentation - JetBrains
IntelliJ IDEA integrates with ESLint which brings a wide range of linting ... Make sure a local Node.js interpreter is configured in your ......
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