grunt警告任务“看”未找到

时间:2013-02-20 10:38:10

标签: gruntjs

Gruntfile.js:

grunt.initConfig({
 watch: {
  compass: {
    files: [
      'app/styles/**/*.{scss,sass}'
    ],
    tasks: 'compass reload'
  },
.....
grunt.registerTask('dev', 'watch');

我跑的时候

grunt dev 

我收到错误

Warning: Task "watch" not found. Use --force to continue. 

我使用grunt-cli v0.1.6和grunt v0.4.0,安装了grunt-contrib-watch。

6 个答案:

答案 0 :(得分:47)

您不必安装整个contrib-package。有一个单独的手表

npm install grunt-contrib-watch --save-dev

最后:

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

答案 1 :(得分:9)

好。

npm install grunt-contrib --save-dev

并在grunt.js的最后一行之前添加此行:

grunt.loadNpmTasks('grunt-contrib');

另外,我必须安装Ruby ...

答案 2 :(得分:0)

实际上,如果未安装该插件,则不会出现错误launcinh grunt watch,只是一个无法加载watch任务的错误。

答案 3 :(得分:0)

我知道这个问题已经过时了,但自从Serge说出来之后,它还没有得到妥善解答。

  

安装了grunt-contrib-watch。

我会检查整个Gruntfile是否被

包装
module.exports = function (grunt) {

};

当您过早关闭此功能(意外)时,您会收到所描述的错误。

答案 4 :(得分:0)

浏览器更新和npm更新对我有用。

答案 5 :(得分:0)

当我在终端上运行grunt watch时遇到错误并修复:

错误

grunt watch
Loading "Gruntfile.js" tasks...ERROR

终端中的FIX

 brew install npm
 brew install node
  • 然后你测试节点和npm工作

    node -v
    npm -v
    
  • 安装Grunt

    npm install -g grunt-cli
    npm install grunt-contrib-watch --save-dev
    
  • 安装Composer

    curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
    
  • 然后跑

    grunt watch 
    

有效!