How to enable JSHint in SublimeLinter in Linux Mint 17 Cinnamon?

Desired behavior

Pointing .js files using Sublime Text 3.

Actual behavior

No dressing occurs.

For example, the following errors are not displayed:

var x = "" 

Playback Steps

Wednesday

  • Linux Mint 17 Cinnamon
  • Sublime Text Build 3065
  • Tools > SublimeLinter > Lint Mode > "Background"
  • Tools > SublimeLinter > Mark Style > "Fill"

In Sublime Text (for installing the SublimeLinter plugin and JSHint)

  • Ctrl + Shift + p
  • Package Management: Package Installation
  • Install SublimeLinter
  • Install SublimeLinter jshint plugin

At the command line

  • Install node.js, npm and jshint with:

    sudo apt-get install nodejs npm
    sudo npm install -g jshint

Close and restart Sublime Text.

Troubleshooting

At the command line:

 hash -r which jshint returns /usr/local/bin/jshint 

I also tried this solution ( https://stackoverflow.com/a/165268/ ), in which manuualy changed the path in Preferences > Package Settings > SublimeLinter > "Settings - User" and restarted Sublime Text, but there were no changes:

 "paths": { "linux": ["/usr/local/bin/jshint"], "osx": [], "windows": [] }, 

Documentation Link

About how to install the jshint plugin:

https://github.com/SublimeLinter/SublimeLinter-jshint

UPDATE

I just ran this on the command line - the results can help troubleshoot:

 jshint --version /usr/bin/env: node: No such file or directory 

This also appears in the Sublime Text Console:

 SublimeLinter: WARNING: no jshint version could be extracted from: /usr/bin/env: node: No such file or directory 
+5
source share
2 answers

JSHint seems to work, but if someone can confirm that this is the best approach that would be great:

https://github.com/joyent/node/issues/3911#issuecomment-8956154

I found that this is often a mistake, if you install from the package manager you can call nodejs, so you just need symlink like this: "ln -s / usr / bin / nodejs / usr / bin / node"

Note. Using this solution, in the Preferences > Package Settings > SublimeLinter > "Settings - User" path, you do not need to configure the paths.

+5
source

The solution provided by you (OP) will work, but I will give some explanation, show you how to check the problem, provide some other options and maybe some best practices (this is what you were looking for when you sent the answer.

Problem

The problem is that the jshint executable is looking for launch using the "node" interpreter, and the system cannot find the executable that matches the name "node" in your path. (I believe that "node" used to be called the standard name, but now it is usually referred to in "nodejs" because there is a problem with the fact that the name "node" is common and contradicts other executables.)

Here is how you can see what is happening ... On the terminal, do the following: - find the path to the jshint executable by executing "which jshint" (you should find it in "/ usr / local / bin") - view the contents by issuing " cat / usr / local / bin ". You will see that the first line uses an interpreter that is "node" (and not "nodejs").

Cause

Currently, when installing Node.js using the package manager, a Debian package named "nodejs" creates the executable "/ usr / bin / nodejs". Therefore, any other executables that define the "node" executable will not find and will not work.

Correction

You have many options:

  • The fastest and easiest. Create a symlink (effectively a "shortcut") for "node" that points to "nodejs". You had a version of this in your answer. It is generally accepted that it is better to use this link in the place of your PATH, except in / usr / bin, for example, in / usr / local / bin. The directory is protected, so you need superuser privileges to create the link at the destination. So the command to release:

      sudo ln -s / usr / bin / nodejs / usr / local / bin / node " 
  • Alternatively, if you are on a system that does not yet have Node.js (or you are uninstalling the current package) when you install it through the package manager, use the "nodejs-legacy" package (instead of nodejs). This package actually creates a link for you automatically. If you already have Node.js installed, you must first uninstall it.

    • To remove the "nodejs" package:
       sudo apt-get remove nodejs 
    • Install "nodejs-legacy" (the one with the link)
       sudo apt-get install nodejs-legacy 
  • Finally, you can install Node.js manually or create it. This is more complicated, and I will not try to explain it all here.

Check

You can verify that jshint can start now by issuing the "jshint -version" command, which should now look something like this:

 $ jshint --version
     jshint v2.5.10 

Happy Line!

+5
source

Source: https://habr.com/ru/post/1207419/


All Articles