简体   繁体   English

Sublime Text 3 SublimeLinter插件无法找到jshint

[英]Sublime Text 3 SublimeLinter plugin not able to find jshint

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 : 出于某种原因,SublimeLinter3或SublimeLinter3 JSHint linter插件似乎无法解析PATH环境变量,因此无法运行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: 但是, jshint二进制文件位于PATH中:

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

The problem only occurs on Ubuntu. 问题只发生在Ubuntu上。 Works flawlessly on OS X. I've scoured through the official docs to no avail. 在OS X上完美运行。我通过官方文档搜索无济于事。

Using bash if that's of any consequence. 如果有任何后果,请使用bash

I eventually fixed this by opening up the SublimeLinter preferences and manually adding the path to the linter: 我最终通过打开SublimeLinter首选项并手动添加到linter的路径来修复此问题:

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

If you don't already have it, you can install via npm : 如果您还没有,可以通过npm安装:

npm install -g jshint

And you find its location with: 你找到它的位置:

which jshint

or in Windows: 或在Windows中:

where jshint

This fix is specific to windows, you could edit your preferences like jorum. 此修复程序特定于Windows,您可以编辑您的首选项,如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 将此添加到变量值的末尾: ;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. 测试:打开命令提示符并键入jshint -v ,您应该获得版本号而不是错误。

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. 您刚刚添加的内容告诉您的操作系统可以找到jshint,您的安装位置可能会有所不同,在这种情况下,只需在系统中搜索一个jshint文件夹,其中包含/ bin文件夹并链接到那里。 NOTE the semi-colon(;) at the beginning separates different PATH's so be sure its included. 注意开头的分号(;)分隔不同的PATH,所以一定要包含它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM