microsoft / vscode-jshint

VSCode extension to integrate jshint into VSCode
https://marketplace.visualstudio.com/items?itemName=dbaeumer.jshint
MIT License
72 stars 58 forks source link

Failed to load jshint library. #79

Open NatoBoram opened 4 years ago

NatoBoram commented 4 years ago

image

I've seen in https://github.com/microsoft/vscode-jshint/issues/50#issuecomment-361024551 that VSCode looks for jshint at $(npm config get prefix)/lib/node_modules. However, this is not true, according to the above screenshot.

ls $(npm config get prefix)/lib/node_modules
eslint  hogan.js  http-server  jshint  npm

JSHint: Show output then Retry give me this.

image

System configuration :

OS: Ubuntu 19.04 x86_64 
Host: 3306A4F ThinkCentre M82 
Kernel: 5.0.0-32-generic 
Uptime: 51 mins 
Packages: 2207 (dpkg), 39 (snap) 
Shell: bash 5.0.3 
Resolution: 1680x1050, 1920x1080 
DE: GNOME 3.32.2 
WM: GNOME Shell 
WM Theme: Adwaita 
Theme: Adwaita-dark [GTK2/3] 
Icons: Yaru [GTK2/3] 
Terminal: gnome-terminal 
CPU: Intel i5-3470 (4) @ 3.600GHz 
GPU: Intel HD Graphics 
Memory: 7465MiB / 15829MiB 
1.40.0-insider
93ee2fc3121b7f66ddf568c051f3bfff7db8d618
x64
jshint v2.10.2
jaysalhan commented 4 years ago

I faced the similar issue and i resolved it recently. Uninstall jshint and js lint extensions from vs code. Then install node.js latest version. Then install jslint and jshint with the help of nodejs cmd by typing "npm install -g jshint/jslint". Once you are done then go to vscode and install jshint and jslint extensions. Reload the vscode. You are done.

epmoyer commented 4 years ago

I am having this issue and don't know how to debug it any further. Running on OSX 10.14.6

If I install jshint locally in the project then it works fine, but I need a global solution.

Thanks

jaysalhan commented 4 years ago

Bro if you have installed nodejs globally then goto nodejs cmd,type jshint/jslint -version

If it say could not be located...kindly type npm install -g jslint/jshint.. For the moment you are doing it..pls uninstall the js hint or lint library from the vscode.

Once you are done installing libraries externally..only then goto vs code and install jshint and jslint libraries..

Thanks Be safe be good Take care

On Fri, 27 Mar 2020, 01:03 Eric Moyer, notifications@github.com wrote:

I am having this issue and don't know how to debug it any further. Running on OSX 10.14.6

  • Completely uninstalled node and reinstalled using brew.
  • From the command line: node works, npm works, jshint installs, and jshint can run/report its version:

bash-3.2$ which jshint /usr/local/bin/jshint bash-3.2$ jshint --version jshint v2.11.0

  • I've set the path explicitly in settings.json: "jshint.nodePath": "/usr/local/bin/jshint",
  • I've uninstalled/reinstalled the jshint extension, cycled VSCode, and cycled the machine.
  • Still I get "Failed to load jshint library", and I don't know how to get any more information about why the extension still can't find it.

If I install jshint locally in the project then it works fine, but I need a global solution.

Thanks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode-jshint/issues/79#issuecomment-604640364, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANZVYJV3NERTWJEFHU7W2PDRJOUYXANCNFSM4JH3MNMA .

jaysalhan commented 4 years ago

And where do you try to debug?? Terminal or with any debugger extension?

On Fri, 27 Mar 2020, 01:03 Eric Moyer, notifications@github.com wrote:

I am having this issue and don't know how to debug it any further. Running on OSX 10.14.6

  • Completely uninstalled node and reinstalled using brew.
  • From the command line: node works, npm works, jshint installs, and jshint can run/report its version:

bash-3.2$ which jshint /usr/local/bin/jshint bash-3.2$ jshint --version jshint v2.11.0

  • I've set the path explicitly in settings.json: "jshint.nodePath": "/usr/local/bin/jshint",
  • I've uninstalled/reinstalled the jshint extension, cycled VSCode, and cycled the machine.
  • Still I get "Failed to load jshint library", and I don't know how to get any more information about why the extension still can't find it.

If I install jshint locally in the project then it works fine, but I need a global solution.

Thanks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode-jshint/issues/79#issuecomment-604640364, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANZVYJV3NERTWJEFHU7W2PDRJOUYXANCNFSM4JH3MNMA .

epmoyer commented 4 years ago

@jaysalhan

Bro if you have installed nodejs globally then goto nodejs cmd,type jshint/jslint -version

I am not sure what you mean by "goto nodejs cmd,type jshint/jslint -version". If you mean get the various package versions from the command line, then yes jshint and jslint are both installed:

bash-3.2$ jshint --version
jshint v2.11.0
bash-3.2$ jslint --version
node-jslint version: 0.12.1  JSLint edition 2013-08-26
bash-3.2$ node --version
v13.11.0
bash-3.2$ npm --version
6.13.7
bash-3.2$

Or alternatively, using npm:

bash-3.2$ npm view jslint version
0.12.1
bash-3.2$ npm view jshint version
2.11.0
bash-3.2$

Once you are done installing libraries externally..only then goto vs code and install jshint and jslint libraries.

I have done this. Many times now. It does not fix the issue.

And where do you try to debug?? Terminal or with any debugger extension?

When I said "don't know how to debug it any further" I meant, I don't know how to determine the root cause of the error that the VSCode jslint extension is reporting. I am not trying to debug any JS code presently. My hope was that someone knows of a log or a way to invoke more verbose error reporting which would shed some light on why the VSCode extension can't find the jshint library, or where it thinks it is looking to find it.

jaysalhan commented 4 years ago

Okay got ya...and whenever you open up vs code it shows a pop up on the right bottom of the screen right?

On Fri, 27 Mar 2020, 01:46 Eric Moyer, notifications@github.com wrote:

@jaysalhan https://github.com/jaysalhan

Bro if you have installed nodejs globally then goto nodejs cmd,type jshint/jslint -version

I am not sure what you mean by "goto nodejs cmd,type jshint/jslint -version". If you mean get the various package versions from the command line, then yes jshint and jslint are both installed:

bash-3.2$ jshint --version jshint v2.11.0 bash-3.2$ jslint --version node-jslint version: 0.12.1 JSLint edition 2013-08-26 bash-3.2$ node --version v13.11.0 bash-3.2$ npm --version 6.13.7 bash-3.2$

Or alternatively, using npm:

bash-3.2$ npm view jslint version 0.12.1 bash-3.2$ npm view jshint version 2.11.0 bash-3.2$

Once you are done installing libraries externally..only then goto vs code and install jshint and jslint libraries.

I have done this. Many times now. It does not fix the issue.

And where do you try to debug?? Terminal or with any debugger extension?

When I said "don't know how to debug it any further" I meant, I don't know how to determine the root cause of the error that the VSCode jslint extension is reporting. I am not trying to debug any JS code presently. My hope was that someone knows of a log or a way to invoke more verbose error reporting which would shed some light on why the VSCode extension can't find the jshint library, or where it thinks it is looking to find it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode-jshint/issues/79#issuecomment-604662132, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANZVYJRAWZS4KI5HKVWM2STRJOZZ7ANCNFSM4JH3MNMA .

epmoyer commented 4 years ago

@jaysalhan

Okay got ya...and whenever you open up vs code it shows a pop up on the right bottom of the screen right?

Correct; the same pop-up noted in the beginning of this issue: Failed to load jshint library. Please install jshint in your workspace folder using 'npm install jshint' or globally using 'npm install -g jshint' and then press Retry.

jaysalhan commented 4 years ago

in the beginning means?Has it stopped popping up?

epmoyer commented 4 years ago

I meant in the beginning of this Github Issue (i.e. the screen shot provided by NatoBoram in the first post). It still pops up every time.

jaysalhan commented 4 years ago

Okay...have you seen the screen shot i sent ?did you try that?

On Fri, 27 Mar 2020, 03:02 Eric Moyer, notifications@github.com wrote:

I meant in the beginning of this Github Issue (i.e. the screen shot provided by NatoBoram in the first post). It still pops up every time.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode-jshint/issues/79#issuecomment-604697812, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANZVYJTPCYIACVCUWSV3WBDRJPCVFANCNFSM4JH3MNMA .

RMacfarlane commented 4 years ago

Sorry I haven't had time to investigate this, I'll be able to do so more next week.

@epmoyer Do you remember if you also installed jshint with sudo? My suspicion is that is fails when it's installed with elevated privileges. Also, what's the output for echo $NODE_PATH? There is a setting for making logging more verbose (jshint.trace.server), but I'm not seeing any additional output from the library used to resolve jshint.

epmoyer commented 4 years ago

Thanks @RMacfarlane! I'd be happy to help and run any experiments you can think of.

$NODE_PATH was not set. I tried setting it (in my shell configuration) to the location of node on my machine (and then uninstalling/reinstalling the jshint extension) but it did not fix the problem.

$ which node
/usr/local/bin/node
$ echo $NODE_PATH
/usr/local/bin/node

I am running an alternate shell (fish rather than bash). I'm not sure if that could be contributing somehow, but I'll try running an experiment later today to swap my default shell back to bash to test.

I still have my command history for the reinstall of node, jshint, and jslint, and none of them were installed with sudo (I had suspected that sudo-ing might be an issue, so that's one of the reasons I uninstalled node and reinstalled it)

$brew install node
$npm install -g jshint
$npm install -g jslint
epmoyer commented 4 years ago

@RMacfarlane Update: I tried switching my default shell back to bash (and uninstalling the jshint extension/closing VSCode/opening VSCode/reinstalling the jshint extension) and the problem persists, so it doesn't appear to be related to the shell.

RMacfarlane commented 4 years ago

Thanks for the updates! I think $NODE_PATH should actually be unset.

For some context on what the extension actually does, it first calls this function to try to get the global node path: https://github.com/microsoft/vscode-languageserver-node/blob/df65330be576a7c4ed834555b0560f780987872e/server/src/files.ts#L127-L170 which should just be ${npm config get prefix}/lib/node_modules, and then it runs this resolve function with 'jshint', the node path, and the path of the current folder: https://github.com/microsoft/vscode-languageserver-node/blob/df65330be576a7c4ed834555b0560f780987872e/server/src/files.ts#L42-L119

In @NatoBoram's case the global node path looks correct, so something in resolve is failing

epmoyer commented 4 years ago

@RMacfarlane

Thanks! It seems likely that the resolve is the issue for me as well. npm config get prefix returns /usr/local, and I can run jshint at /usr/local/lib/node_modules/jshint/bin/jshint per the experiment below.

$ which jshint
/usr/local/bin/jshint
$ ls -l /usr/local/bin/jshint
lrwxr-xr-x  1 eric  admin  37 Mar 26 12:51 /usr/local/bin/jshint -> ../lib/node_modules/jshint/bin/jshint

$ npm config get prefix
/usr/local
$ ls -l  /usr/local/lib/node_modules/jshint/bin/jshint
-rwxr-xr-x  1 eric  admin  71 Oct 26  1985 /usr/local/lib/node_modules/jshint/bin/jshint
$ /usr/local/lib/node_modules/jshint/bin/jshint --version
jshint v2.11.0