这看起来很简单,但我似乎无法调试这个错误。我已经将这段代码添加到我的Sails中,作为/tasks/config/jshint.js。
module.exports = function(grunt) {
console.log(1);
grunt.config.set('jshint', {
files: {
src: ['api/services/*.js', 'api/policies/*.js', 'api/controllers/*.js']
}
});
console.log(2);
grunt.loadNpmTask('grunt-contrib-jshint');
console.log(3);
};现在,当我执行任何普通任务时,都会收到一条错误消息(但旧任务仍然成功执行)。
C:\dev\fo-rest-api>grunt aglio
1
2
Loading "Gruntfile.js" tasks...ERROR
>> TypeError: undefined is not a function
Running "aglio:your_target" (aglio) task
...
Done, without errors.当我运行jshint任务时,我会得到相同的加载错误,并且任务将被中止。
C:\dev\fo-rest-api>grunt jshint
1
2
Loading "Gruntfile.js" tasks...ERROR
>> TypeError: undefined is not a function
Warning: Task "jshint" not found. Use --force to continue.
Aborted due to warnings.
C:\dev\fo-rest-api>还有几个注意事项:
--force只会更改错误消息的措辞。npm install。loadNpmTask行,看看sails是否会自动加载它,但还是得到了Warning: Task "jshint" not found.谢谢你提供的任何线索。
发布于 2016-03-03 01:32:10
答案很直截了当。我以某种方式在s的末尾删除了grunt.loadNpmTasks。当我把它加回去的时候,一切都很顺利。
我希望有某种语法强调,对于常见的包,如咕噜,将识别这种类型的错误.
https://stackoverflow.com/questions/35737243
复制相似问题