I have installed jshint
using the following command
npm install -g jshint
I have test.js file with the following statement
console.log(a)
I tested the file using the following command
jshint test.js
Problem: jshint is not working
It should throw the following error/warning
One warning - Missing semicolon
One undefined variable - a
Contents of .jshintrc file
{
"bitwise" : true, // Prohibit bitwise operators (&, |, ^, etc.).
"curly" : true, // Require {} for every new block or scope.
"eqeqeq" : true, // Require triple equals i.e. `===`.
"forin" : true, // Tolerate `for in` loops without `hasOwnPrototype`.
"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
"latedef" : true, // Prohibit variable use before definition.
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
"noempty" : true, // Prohibit use of empty blocks.
"nonew" : true, // Prohibit use of constructors for side-effects.
"plusplus" : true, // Prohibit use of `++` & `--`.
"regexp" : true, // Prohibit `.` and `[^...]` in regular expressions.
"undef" : true, // Require all non-global variables be declared before they are used.
"strict" : true, // Require `use strict` pragma in every file.
"trailing" : true // Prohibit trailing whitespaces.
}
Note: I have tried re-installing jshint with reference as well.
Any suggestion will be grateful.
Installing
Node
an npm through the official repositories has always given me trouble. I suspect that this could be due to tools depending onnode
, when the actual command on Ubuntu isnodejs
.Follow the steps to make jshint work
Remove node and npm
Reinstall the node using nvm. Following command will do the stuff.
Note: Now you should be able to run Node with the
node
command, you should be able to install modules globally withoutsudo
Now install the
jshint
globally using the following commandNow
jshint
will work like a charm :)