没有这样的文件或目录:'jshint'

No such file or directory: 'jshint'

在 sublime text 上,我在尝试验证 JS 时遇到以下错误。

[Errno 2] No such file or directory: 'jshint'
[cmd: ['jshint', '/Users/vladislavkopylov/Downloads/test.js', '--reporter', '/Users/vladislavkopylov/Library/Application Support/Sublime Text 3/Packages/JSHint/reporter.js']]
[dir: /Users/vladislavkopylov/Downloads]
[path: /usr/local/share/npm/bin:/usr/local/bin:/opt/local/bin]
[Finished]

我正在使用 Sublime 3 && Debian 9.3 并遇到了同样的问题。这是我的解决方案:

1) npm 安装-g jshint

2) Preferences -> Browse Packages... 然后打开 JSHint/JSHint.py (/home/user/.config/sublime-text-3/Packages/JSHint/JSHint.py)

搜索:

if sublime.platform() == "windows":
    args['cmd'][0] += ".cmd"
elif sublime.platform() == "osx":
    args['path'] = "/usr/local/share/npm/bin:/usr/local/bin:/opt/local/bin"

我在那之后添加了以下行(覆盖 args['path']):

args['path'] = "/home/alexismaster/.nvm/v0.10.29/bin:/usr/local/share/npm/bin:/usr/local/bin:/opt/local/bin"

即我添加了这条路径:/home/alexismaster/.nvm/v0.10.29/bin 这个条件似乎是不必要的,因为我的 OS 无论如何都不存在

你可能有不同,因为我使用的是 NVM,目前版本是 0.10.29

3) 重启 Sublime