Sublime Text 3 SublimeLinter plugin not able to find jshint
Asked Answered
D

2

10

For some reason, SublimeLinter3, or the SublimeLinter3 JSHint linter plugin, seems unable to parse the PATH environment variable and is thus unable to run jshint:

SublimeLinter: Could not parse shell PATH output:
<empty> 
error: SublimeLinter could not determine your shell PATH. It is unlikely that any linters  will work. 

Please see the troubleshooting guide for info on how to debug PATH problems.
SublimeLinter: WARNING: jshint deactivated, cannot locate 'jshint' 
Can't connect
Unable to fetch update url contents

The jshint binary is in the PATH, however:

$ which jshint
/home/path/to/bin/jshint

The problem only occurs on Ubuntu. Works flawlessly on OS X. I've scoured through the official docs to no avail.

Using bash if that's of any consequence.

Dorina answered 7/1, 2014 at 7:56 Comment(1)
I experience exact same issue on OS X (El Capitan) with oh-my-zsh installed. Not an issue with the default bash shell.Verism
D
15

I eventually fixed this by opening up the SublimeLinter preferences and manually adding the path to the linter:

"paths": {
    "linux": ["/path/to/jshint/bin"],
    "osx": [],
    "windows": []
},

If you don't already have it, you can install via npm:

npm install -g jshint

And you find its location with:

which jshint

or in Windows:

where jshint
Dorina answered 18/1, 2014 at 11:0 Comment(7)
A Windows example which worked for me was: "paths": { "linux": [], "osx": [], "windows": ["C:/Users/myUserName/AppData/Roaming/npm"] }Islamism
How did you open SublimeLinter's preferences?Mingmingche
@Imray Preferences > Package Settings > Sublime Linter > Settings - UserDorina
When I copy that in, I get an error Error trying to parse settings: Unexpected trailing characters 1:8Mingmingche
@Imray Copy what in exactly? Did you forget the trailing , at the end of the line?Dorina
@Imray If your file is empty when you first open it, copy the entire contents of SublimeLinter's Settings - Default file first, then edit the affected rows.Dorina
@jorum But in Settings - Default there's no "paths:"Mingmingche
P
6

This fix is specific to windows, you could edit your preferences like jorum. OR you can add it to your windows "Path" which may be more helpful in the future.

Start > Control Panel > System > Advanced System Settings > Environment Variables...

Select your PATH and click edit.

ADD this to the end of the Variable Value: ;C:\Users\YOURUSERNAMEHERE\node_modules\jshint\bin

TO TEST: Open a command prompt and type jshint -v and you should get a version number and not an error.

What you just did was added told your OS where it can find jshint, your install location may be different, in that case just search for a jshint folder on your system that has a /bin folder inside it and link there instead. NOTE the semi-colon(;) at the beginning separates different PATH's so be sure its included.

Punjabi answered 4/9, 2014 at 17:20 Comment(2)
Thank you for including an answer for windows users :)Vestal
My Windows 7 machine needed the path C:/Users/myUserName/AppData/Roaming/npm instead. You can find the right path for your system by seaching your User folder for jshint.cmd.Zoarah

© 2022 - 2024 — McMap. All rights reserved.