JSHint 不工作
JSHint is not working
我已经使用以下命令安装了 jshint
npm install -g jshint
我有 test.js 包含以下语句的文件
console.log(a)
我使用以下命令测试了文件
jshint test.js
问题:jshint 不工作
它应该抛出以下 error/warning
一个警告 - 缺少分号
一个未定义的变量 - a
.jshintrc 文件的内容
{
"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.
}
注意:我也尝试过使用 reference 重新安装 jshint。
任何建议将不胜感激。
通过官方存储库安装 Node
npm 一直给我带来麻烦。我怀疑这可能是由于工具依赖于 node
,而 Ubuntu 上的实际命令是 nodejs
.
按照步骤使 jshint 工作
删除节点和 npm
使用 nvm 重新安装节点。以下命令将执行这些操作。
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
注意: 现在你应该可以 运行 使用 node
命令节点,你应该可以在没有 [=16] 的情况下全局安装模块=]
现在使用以下命令全局安装 jshint
npm install -g jshint
现在 jshint
会很有魅力:)
jshint
npm install -g jshint
我有 test.js 包含以下语句的文件
console.log(a)
我使用以下命令测试了文件
jshint test.js
问题:jshint 不工作
它应该抛出以下 error/warning
一个警告 - 缺少分号
一个未定义的变量 - a
.jshintrc 文件的内容
{
"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.
}
注意:我也尝试过使用 reference 重新安装 jshint。
任何建议将不胜感激。
通过官方存储库安装 Node
npm 一直给我带来麻烦。我怀疑这可能是由于工具依赖于 node
,而 Ubuntu 上的实际命令是 nodejs
.
按照步骤使 jshint 工作
删除节点和 npm
使用 nvm 重新安装节点。以下命令将执行这些操作。
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
注意: 现在你应该可以 运行 使用
node
命令节点,你应该可以在没有 [=16] 的情况下全局安装模块=]现在使用以下命令全局安装
jshint
npm install -g jshint
现在 jshint
会很有魅力:)