【发布时间】:2016-06-14 17:12:27
【问题描述】:
这看起来很简单,但我似乎无法调试此错误。我已将此代码作为 /tasks/config/jshint.js 添加到我的 Sails API 中
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);
};
现在,当我执行任何 grunt 任务时,我都会收到一条错误消息(但旧任务仍然成功执行)。
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只会更改错误消息的措辞。 - grunt-contrib-jshint 似乎已成功安装在 /node_modules 中(我删除了所有内容并重新运行
npm install以确保。 - 我在 Windows 上运行它,如果这很重要的话。我尝试以普通用户和管理员的身份打开命令行。
- 我尝试注释掉
loadNpmTask行以查看sails 是否会自动加载它,但仍然得到Warning: Task "jshint" not found.
感谢您提供的任何线索。
【问题讨论】:
标签: gruntjs sails.js grunt-contrib-jshint