为什么我会向Travis-CI发出有关模块未定义的警告?

时间:2016-01-19 20:49:09

标签: javascript travis-ci

找到Travis-CI页面here

         } else if (typeof module === 'object' && module.exports) {
                                                      ^ 'module' is not defined.
           module.exports = function( root, jQuery ) {
               ^ 'module' is not defined.
>> 2 errors in 1 file
Warning: Task "jshint:main" failed. Use --force to continue.
Aborted due to warnings.

显然,这些事件都是模块受 if 语句或short-circuit evaluation保护。这完全有效,为什么会产生警告?

3 个答案:

答案 0 :(得分:0)

在使用变量使JSLint满意之前,需要声明变量。所以你需要一个

var module;

在有问题的代码之前声明。

答案 1 :(得分:0)

您的困惑源于习惯于运行JavaScript来获得此结果。正如@Barmar所说,你有一个简单的未声明的变量。 jshint没有评估if语句前半部分的检查;它只是在抱怨module尚未定义。

答案 2 :(得分:0)

不要声明module。 您需要将其添加到jshint配置

/*jshint node:true */

相关问题