Domanda

I want to set my Grunt.js file to launch my MAMP server on grunt serve.

I have been trying to use this tutorial here to do this:

https://coderwall.com/p/kwne-g

I was then planning to use this tutorial to set up grunt watch:

http://darrenhall.info/development/yeoman-and-mamp

Now I am having trouble with step one. I have successfully installed grunt exec. However, grunt claims not to be able to find the task 'serverup'.

Here is my code:

 grunt.task.run([
        'clean:server',
        'concurrent:server',
        'autoprefixer',
        'connect:livereload',
        'serverup',
        'watch',
        'serverdown'
]);
È stato utile?

Soluzione

If you followed the examples at the link, it looks like your targets should be exec:serverup and exec:serverdown for the tasks to work.

The problem here and with many other Grunt related questions is that without the full Gruntfile, "answers" are largely guesses. Configuration, task loading, and task registration are all related and without seeing all three, it is difficult to say "this is the answer".

Given that, here's a checklist I use for problems like this when using Grunt and packages from NPM:

  1. Is the code that supports the task installed? Did I forget npm install? Did I miss errors on install (check npm-debug.log if it exists)?
  2. Have I correctly used grunt.loadNpmTasks for the plugin? Is the line in my Gruntfile and did I get the plugin name spelled correctly? Did I or my IDE accidentally use to grunt.loadTasks when I need loadNpmTasks?
  3. Have I correctly named/used grunt.registerTask for the task? If I need to call a specific target for a task, do I have the the name correctly specified?
  4. If there are paths involved and things are broken, do I have my globbing patterns correctly specified? If a cwd is involved, do I have the other paths or files correctly specified?
  5. Did I get the configuration right? (This is where things get too plugin-specific for a checklist.)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top