Javascript JSHint和grunt.js-未定义Highcharts

Javascript JSHint和grunt.js-未定义Highcharts,javascript,angularjs,highcharts,gruntjs,jshint,Javascript,Angularjs,Highcharts,Gruntjs,Jshint,我正在使用Angular应用程序,一旦我对grunt.js的所有内容都满意,我就运行grunt.js来构建分发版,在那里所有内容都被缩小了,现在我的问题开始了。当文件没有缩小时,所有Highcharts都可以正常工作,一旦我缩小js文件,我得到的错误是Highcharts没有定义 highcharts的部分代码,其中我得到了一些错误提示,请参阅错误注释: function createDevicesChart (title) { Highcharts.setOptions ({ //er

我正在使用Angular应用程序,一旦我对grunt.js的所有内容都满意,我就运行grunt.js来构建分发版,在那里所有内容都被缩小了,现在我的问题开始了。当文件没有缩小时,所有Highcharts都可以正常工作,一旦我缩小js文件,我得到的错误是Highcharts没有定义

highcharts的部分代码,其中我得到了一些错误提示,请参阅错误注释:

function createDevicesChart (title) {
    Highcharts.setOptions ({ //error Highcharts is not defined, unresolved variable Highcharts, unresolved function setOptions
        lang: {rangeSelectorZoom: ''},
        colors: ['#F4D00B']
    });
    Highcharts.RangeSelector.prototype.render = (function (func) { //error Highcharts is not defined, unresolved variable Highcharts, unresolved variable RangeSelector
        return function () {
            func.apply (this, arguments);
            var leftPosition = this.chart.plotLeft,
            topPosition = this.chart.plotTop,
            space = 1;
            var widthChart = this.chart.chartWidth;
            var widthChartHolder = $ ('.highcharts-container >svg').width ();
            //console.log(widthChartHolder);
            for (var i = 0; i < this.buttons.length; i++) {
                this.buttons[i].attr ({
                    x: widthChartHolder - leftPosition - 41,
                    y: topPosition - 77
                });
                leftPosition += this.buttons[i].width + space;
            }
        };
    } (Highcharts.RangeSelector.prototype.render));//error Highcharts is not defined, unresolved variable RangeSelector

        .........//rest of the code 


    angular.element('#devices_chart').highcharts ('StockChart', chartingOptions); //unresolved function or method highcharts()

}
有人能帮我吗? 我在这里真的很挣扎:( 非常感谢

编辑:即使我用Highcharts的假值更新了jshintr,当我运行grunt作业时,它会缩小所有代码,并且我在控制台中再次得到错误:

ReferenceError: Highcharts is not defined
    at m (http://localhost/myAPP/dist/scripts/scripts.js:1:3021)
    at link (http://localhost/myAPP/dist/scripts/scripts.js:1:3125)
    at http://localhost/myAPP/dist/scripts/vendor.js:4:20180
    at s (http://localhost/myAPP/dist/scripts/vendor.js:4:14727)
    at h (http://localhost/myAPP/dist/scripts/vendor.js:4:10779)
    at h (http://localhost/myAPP/dist/scripts/vendor.js:4:10796)
    at http://localhost/myAPP/dist/scripts/vendor.js:4:10402
    at http://localhost/myAPP/dist/scripts/vendor.js:7:19333
    at s (http://localhost/myAPP/dist/scripts/vendor.js:4:14727)
    at h (http://localhost/myAPP/dist/scripts/vendor.js:4:10779) <div id="devices_chart" class="ng-isolate-scope"> 
ReferenceError:未定义Highcharts
在m(http://localhost/myAPP/dist/scripts/scripts.js:1:3021)
在链接(http://localhost/myAPP/dist/scripts/scripts.js:1:3125)
在http://localhost/myAPP/dist/scripts/vendor.js:4:20180
在s(http://localhost/myAPP/dist/scripts/vendor.js:4:14727)
在h(http://localhost/myAPP/dist/scripts/vendor.js:4:10779)
在h(http://localhost/myAPP/dist/scripts/vendor.js:4:10796)
在http://localhost/myAPP/dist/scripts/vendor.js:4:10402
在http://localhost/myAPP/dist/scripts/vendor.js:7:19333
在s(http://localhost/myAPP/dist/scripts/vendor.js:4:14727)
在h(http://localhost/myAPP/dist/scripts/vendor.js:4:10779)  

您必须告诉jshint如何处理此类全局变量

在项目的根目录下创建一个
.jshintrc
配置文件,其中包含:

{
    // JSHint Default Configuration File (as on JSHint website)
    // See http://jshint.com/docs/ for more details

    //[...] // global conf ... see docs

    // Custom Globals
    "globals" : {
        "Highcharts"  : false //here is what you need
    }
}

请参见Grunt配置中的
jshintrc
选项,您可能错过了该选项

grunt.initConfig({
    jshint: {
        options: {
            jshintrc: true
        }
    }
});

不要忘记开头的点:.jshintrcI have.dot-我知道事实上.jshintrc在我设置角度全局值时工作-没有它,我的应用程序将无法运行,我甚至使用了grunt--force,但这给了我同样的错误
grunt.initConfig({
    jshint: {
        options: {
            jshintrc: true
        }
    }
});