简体   繁体   中英

Grunt Watch not working with file base set to subdirectory

I'm having an issue where Grunt Watch is not working with my subdirectory using Grunt. Here's my directory setup:

/home
  --/repos
      --/common
        --/node_modules
        -- gruntfile.js
        -- package.json

And I've set the base manually to the home directory in my gruntfile:

grunt.file.setBase('../../');

I'd like to keep my gruntfile located in this directory for working with other folks on my team and not use multiple gruntfiles.

Running 'grunt' works just fine. However, when I have Grunt Watch running, I get an error when I update my files:

Waiting...OK
>> File "repos/common/js/controllers/UserCtrl.js" changed.

grunt-cli: The grunt command line interface. (v0.1.13)

Fatal error: Unable to find local grunt.

Here is the watch portion of my gruntfile:

watch: {

  // js
  js: {
    files: [
      'js/*.js',
      'js/controllers/*.js',
      'js/services/*.js',
      'js/lib/*.js',
      'm/js/*.js',
      'm/js/controllers/*.js',
      'm/js/services/*.js',
      'm/js/lib/*.js',
      'repos/common/js/controllers/*.js',
      'repos/common/js/services/*.js',
      'repos/common/js/lib/*.js',
    ],
    tasks: ['concat']
  },

  // css
  css: {
    files: [
      'repos/common/less/*.less',
      'm/less/*.less',
      'css/*.css',
      'repos/common/css/lib/*.css',
    ],
    tasks: ['newer:less', 'newer:cssmin', 'newer:concat_css']
  }
}

What on earth am I not getting here? Any help would be super appreciated!

You missed installing the grunt module

The grunt-cli is a different module to the actual grunt . I think you should install grunt (that is what is meant with the local error message) at the local directory or above where your gruntfile.js is located.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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