Gruntjs Grunt grunfile.js和Grunt watch

Gruntjs Grunt grunfile.js和Grunt watch,gruntjs,grunt-contrib-watch,grunt-contrib-compass,Gruntjs,Grunt Contrib Watch,Grunt Contrib Compass,**我希望能够使用指南针,但Grunt手表不工作,并给我奇怪的错误:** Running "watch" task Waiting...Verifying property watch exists in config...ERROR >> Unable to process task. Warning: Required config property "watch" missing. /Applications/MAMP/htdocs/davide77.bitbucket.or

**我希望能够使用指南针,但Grunt手表不工作,并给我奇怪的错误:**

Running "watch" task
Waiting...Verifying property watch exists in config...ERROR
>> Unable to process task.
Warning: Required config property "watch" missing.

/Applications/MAMP/htdocs/davide77.bitbucket.org/sky-route-1/node_modules/grunt-contrib-compass/node_modules/tmp/lib/tmp.js:261
  throw err;
        ^
RangeError: Maximum call stack size exceeded
module.exports=函数(grunt){
//项目配置。
grunt.initConfig({
pkg:grunt.file.readJSON('package.json'),
指南针:{
开发人员:{
src:“sass”,
dest:'样式表',
outputstyle:“已扩展”,
评论:是的,
对,,
要求:[
"搞活sass",,
“mylib”
],
是的,
图像:'/assets/images',
相对论:对
},
产品:{
src:“sass”,
dest:'样式表',
outputstyle:'压缩',
linecomments:false,
对,,
要求:[
"搞活sass",,
“mylib”
],
调试:错误,
图像:'/assets/images',
相对论:对
},
地区:{
src:“sass”,
dest:'样式表',
outputstyle:'压缩',
linecomments:false,
对,,
要求:[
"搞活sass",,
“mylib”
],
调试:错误,
图像:'/assets/images',
相对论:对
},
watch:{//对于开发运行“grunt watch”
指南针:{
文件:['sass/*.scss'],
任务:['compass:dev']
}
}
}
});
//默认任务。
//registerTask('default','compass:dev');
grunt.registerTask('watch',['watch']);
grunt.loadTasks('watch');
grunt.loadNpmTasks(“grunt-contrib-watch”);
grunt.loadNpmTasks(“grunt-contrib-compass”);
registerTask('default',['compass']);
};

我已经重新格式化了您的代码,现在您应该看到您将watch配置放在了compass config对象中,这是不正确的

另外,为什么要包含此代码:

grunt.registerTask('watch', ['watch']);
grunt.loadTasks('watch');

可能这也会引起一些问题,我建议删除它

我已经重新格式化了您的代码,现在您应该看到您已经将watch配置放在compass config对象中,这是不正确的

另外,为什么要包含此代码:

grunt.registerTask('watch', ['watch']);
grunt.loadTasks('watch');
可能这也会引起一些问题,我建议删除它

我认为这一部分:

grunt.registerTask('watch', ['watch']);
grunt.loadTasks('watch');

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.registerTask('default', ['compass']);
应该是这样的:

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');

grunt.registerTask('watch', ['watch']);
grunt.registerTask('default', ['compass']);
我认为这一部分:

grunt.registerTask('watch', ['watch']);
grunt.loadTasks('watch');

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.registerTask('default', ['compass']);
应该是这样的:

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');

grunt.registerTask('watch', ['watch']);
grunt.registerTask('default', ['compass']);

对我来说很明显,设置任务->
grunt.initConfig
,注册它。然后加载它。我建议将您的问题标记为答案这对我来说很明显,设置任务->
grunt.initConfig
,注册它。然后加载它。我建议把你的问题标记为答案