[英]JSHint is not working
I have installed jshint
using the following command 我已经使用以下命令安装了jshint
npm install -g jshint
I have test.js file with the following statement 我有带有以下语句的test.js文件
console.log(a)
I tested the file using the following command 我使用以下命令测试了文件
jshint test.js
It should throw the following error/warning 它应该抛出以下错误/警告
One warning - Missing semicolon 一个警告-缺少分号
One undefined variable - a 一个未定义的变量-a
{
"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.
}
Any suggestion will be grateful. 任何建议将不胜感激。
Installing Node
an npm through the official repositories has always given me trouble. 通过官方存储库安装Node
npm总是给我带来麻烦。 I suspect that this could be due to tools depending on node
, when the actual command on Ubuntu is nodejs
. 我怀疑这可能是由于依赖于node
工具所致,而Ubuntu上的实际命令是nodejs
。
Remove node and npm 删除节点和npm
Reinstall the node using nvm. 使用nvm重新安装该节点。 Following command will do the stuff. 下面的命令将做的事情。
curl https://raw.githubusercontent.com/creationix/nvm/v0.15.0/install.sh | bash source ~/.nvm/nvm.sh nvm install 0.12 nvm use 0.12
Note: Now you should be able to run Node with the node
command, you should be able to install modules globally without sudo
注意:现在您应该可以使用node
命令运行Node,应该可以在没有sudo
情况下全局安装模块了。
Now install the jshint
globally using the following command 现在,使用以下命令全局安装jshint
npm install -g jshint
Now jshint
will work like a charm :) 现在, jshint
会像魅力一样工作:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.