繁体   English   中英

grunt警告任务“看”未找到

[英]grunt Warning Task “watch” not found

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。

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

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

最后:

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

好。

npm install grunt-contrib --save-dev

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

grunt.loadNpmTasks('grunt-contrib');

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

实际上,如果没有安装插件,你就不会有错误launcinh grunt watch ,只是一个无法加载watch任务的错误。

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

安装了grunt-contrib-watch。

我会检查整个Gruntfile是否被包装

module.exports = function (grunt) {

};

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

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

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

错误

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

在终端修复

 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 

有效!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM