Every time Visual Studio Code started or loaded it shows an error message:
«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«.
Is there any solution available?
Abdollah
4,4593 gold badges28 silver badges48 bronze badges
asked May 1, 2016 at 10:18
You’ll need to follow the prompt and install jshint.
For just the workspace
npm install jshint
or
For all your workspaces
npm install -g jshint
answered May 2, 2016 at 15:12
Wade AndersonWade Anderson
2,4511 gold badge20 silver badges21 bronze badges
6
I had this problem while I had installed jshint
using yarn
globally (yarn global add jshint
). I added the following properties to settings.json
for User
to solve the problem:
"jshint.packageManager": "yarn",
"jshint.nodePath": "/usr/local/lib/node_modules/"
The first property i.e. jshint.packageManager
specifies that yarn
is used to manage node
packages instead of npm
. The second one i.e. jshint.nodePath
specifies the path of jshint
installation. To check if jshint
is loaded successfully, I opened Command pallet ( CTRL + 3) and ran command JSHint: Show output
which showed this message in the output:
jshint library loaded from /usr/local/lib/node_modules/jshint/src/jshint.js
It indicated that the problem was resolved. Afterwards, the jshint
messages appeared in *.js
files.
answered Sep 11, 2019 at 12:12
AbdollahAbdollah
4,4593 gold badges28 silver badges48 bronze badges
2
Open cmdr
or the Git bash terminal and enter npm install -g jshint
, then exit VS code and re-open it.
Malekai
4,7235 gold badges25 silver badges60 bronze badges
answered Oct 10, 2020 at 21:44
For applying the changes to Global scope, and not only to a specific Workspace, use the following command in terminal:-
npm install -g jshint
For a particular workspace, use the following command in terminal:-
npm install jshint
answered Jun 10, 2018 at 15:23
Use sudo before npm install jshint
For the current workspace
sudo npm install jshint
or
For all your workspaces
sudo npm install -g jshint
Using sudo
with a command in LINUX/UNIX generally gives you the permissions to root level.
The root user has permission to access, modify or delete almost any file on your computer. Normal user accounts can access, modify or delete fewer files. This restrictions on normal user accounts are to protect your computer from unauthorized and harmful programs or users.
Thus, running the installation command with sudo
gives you the permissions of the superuser, and allows you to modify files that your normal user doesn’t have permission to modify.
answered May 27, 2021 at 4:14
Visual Studio Code is a popular code editor among software developers, which offers features such as syntax highlighting, autocompletion, and debugging tools. However, sometimes users may encounter an error «Failed to load jshint library» while using Visual Studio Code. This error typically occurs when the user is trying to lint a JavaScript file, and the linter (jshint) fails to load the required library files. This error can cause issues with the functionality of the code editor and make it difficult for users to write and debug their code.
Method 1: Installing the jshint Extension
- Open Visual Studio Code
- Click on the «Extensions» icon on the left sidebar (or press
Ctrl+Shift+X
) - Search for «jshint» in the search bar
- Click on the «Install» button for the «jshint» extension by Dirk Baeumer
- Wait for the installation to complete
- Once installed, reload Visual Studio Code
You should now be able to use jshint in Visual Studio Code without any issues.
Example code:
function addNumbers(num1, num2) {
return num1 + num2;
}
addNumbers(2, 3);
This code will now be checked by jshint and any errors or warnings will be displayed in the «Problems» tab at the bottom of the screen.
Explanation:
The jshint extension provides a linter for JavaScript code in Visual Studio Code. It checks your code for errors and warnings, and provides suggestions for how to improve your code. By installing the jshint extension, you can use this linter in Visual Studio Code without any additional setup.
Method 2: Updating the Settings in Visual Studio Code
To update the settings in Visual Studio Code to fix the «Failed to load jshint library» error, follow these steps:
- Open Visual Studio Code and go to File -> Preferences -> Settings (or press
Ctrl + ,
on Windows/Linux orCmd + ,
on Mac). - In the search bar, type «jshint» and click on «Edit in settings.json» to open the settings file.
- Add the following line to the settings file:
This enables jshint in Visual Studio Code.
- If you still encounter the error, try specifying the path to the jshint library by adding the following line to the settings file:
"jshint.options": { "esversion": 6, "globalstrict": true },
"jshint.path": "/path/to/jshint"
Replace «/path/to/jshint» with the actual path to the jshint library on your system.
- Save the settings file and restart Visual Studio Code.
With these settings, jshint should be enabled and the «Failed to load jshint library» error should be resolved.
Method 3: Updating the Global jshint Package
To fix the Visual Studio Code error «Failed to load jshint library», you can try updating the global jshint package. Here are the steps:
- Open your terminal or command prompt.
- Install or update the jshint package globally by running the following command:
- Check the version of the jshint package by running the following command:
- Open Visual Studio Code and go to the settings (File > Preferences > Settings).
- Search for «jshint» in the search bar.
- Under «Jshint: Path», enter the path to the jshint executable. If you installed it globally, the path should be «/usr/local/bin/jshint» on macOS/Linux or «C:Users{username}AppDataRoamingnpmjshint.cmd» on Windows.
- Save the settings and close Visual Studio Code.
- Reopen Visual Studio Code and try running jshint again.
function sum(a, b) {
return a + b;
}
sum(1, 2);
This should now work without the «Failed to load jshint library» error.
Note: If you don’t want to install the jshint package globally, you can also install it locally in your project directory and point the «Jshint: Path» setting to the local executable.
Method 4: Installing jshint Locally in the Project Folder
If you are encountering the error «Failed to load jshint library» in Visual Studio Code, you can fix it by installing jshint locally in the project folder. Here are the steps to do it:
-
Open the terminal in Visual Studio Code by pressing
Ctrl + ~
or clicking onTerminal
>New Terminal
. -
Navigate to the root folder of your project by running the following command:
- Install jshint locally in your project folder by running the following command:
npm install jshint --save-dev
- Once the installation is complete, create a
.jshintrc
file in the root folder of your project using the following command:
- Open the
.jshintrc
file in Visual Studio Code and add the following code:
{
"node": true,
"globals": {
"jQuery": true,
"$": true
}
}
-
Save the
.jshintrc
file and restart Visual Studio Code. -
Finally, open the JavaScript file that was giving you the error and the error should be gone.
That’s it! You have successfully fixed the «Failed to load jshint library» error in Visual Studio Code by installing jshint locally in the project folder.
I have a large project, that’s split into micro services, the problem is that node_modules
for a frontend part is nested in a few folders, because I use root folder. So, I don’t wanna install anything globally (that’s why I use docker all the time), I just wanna to specify the path for the jshint
library in its config. Is it possible? Btw, it works fine in WebStorm for example, but WebStorm works a bit slower than VS Code because of indexing the code and so on.
Solution 1
You’ll need to follow the prompt and install jshint.
For just the workspace
npm install jshint
or
For all your workspaces
npm install -g jshint
Solution 2
I had this problem while I had installed jshint
using yarn
globally (yarn global add jshint
). I added the following properties to settings.json
for User
to solve the problem:
"jshint.packageManager": "yarn",
"jshint.nodePath": "/usr/local/lib/node_modules/"
The first property i.e. jshint.packageManager
specifies that yarn
is used to manage node
packages instead of npm
. The second one i.e. jshint.nodePath
specifies the path of jshint
installation. To check if jshint
is loaded successfully, I opened Command pallet ( CTRL + 3) and ran command JSHint: Show output
which showed this message in the output:
jshint library loaded from /usr/local/lib/node_modules/jshint/src/jshint.js
It indicated that the problem was resolved. Afterwards, the jshint
messages appeared in *.js
files.
Solution 3
Just go to cmdr or git bash terminal and open.
write «npm install -g jshint» exit vs code then RE-open Vs-code.
Solution 4
For applying the changes to Global scope, and not only to a specific Workspace, use the following command in terminal:-
npm install -g jshint
For a particular workspace, use the following command in terminal:-
npm install jshint
Related videos on Youtube
00 : 51
How to resolve jshint es6 support warning in VS Code
06 : 24
The ‘CodeMaidPackage’ package did not load correctly Error Solved Visual Studio | Tutorial4You
01 : 36
10 : 10
Hướng dẫn cài đặt VSCode — Tổng hợp các VS Code Extension bá đạo bạn nên có
08 : 01
How to Run Javascript in Visual Studio Code on Windows 10 2022
06 : 45
Khắc phục Live Server extension không chạy được trình duyệt trong Visual Studio Code
02 : 20
JSHint- JavaScript Code Quality Tool, detect errors and potential
13 : 01
Detect Errors in your Javascript Code with ESLint
02 : 03
Настройка плагина jshint | jshint настройка
02 : 43
How to fix the ‘let’ is available in ES6 error in VS Code
Comments
-
Every time Visual Studio Code started or loaded it shows an error message:
«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«.
Is there any solution available? -
I tried for all workspaces with the second command; it works. Thanks.
-
Did not work for me. On Windows 7, I installed node.js which includes npm. Then I ran
npm install jshint
(and also tried the global install). But I still get the error message from the question. Any other things I have to set up? -
Okay, I think it’s working now. For some reason I thought I would have to run the command as admin. But it only worked after running it as user.
-
The suggested commands only worked for me when they was issued in the terminal of VS Code itself.
-
I’m using VS Code with python and I am getting this same message. I installed for the workspace but then when I need to create a new workspace I need to do it all over again. Is there a way to fix this for all newly created workspaces without installing globally? Or, do I even need it for my Python workspace?
-
Thanks! For me, the answer was to simply set nodePath for jshint. The error message was (wrongly) telling me to install jshint because it couldn’t find the global node_modules folder.
-
Following the advice on this page, in addition to doing the above, I had to add two lines to VSC’s settings file,
~/.config/Code/User/settings.json
:"jshint.packageManager": "npm"
and"jshint.nodePath": "/usr/local/lib/node_modules/"
. (The page had yarn as the package manager, but I use npm.) Then I closed and restarted VSC, and got a dialog asking me how I wanted to use the jshint library; I clicked the «Allow Everywhere» option.
Recents
Related
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.