How to load a task using loadNpmTask in a grunt file if the module is in a different directory
Attempting to load a module: grunt.loadNpmTasks('grunt-express-server');
from an external directory.
Get error message: task .... does not exist. Did you download it?
Directory structure:
client/ node_modules gruntfile dev_server/ node_modules/ grunt-express-server
So my question is, how do I execute a grunt task using a node-module that is stored in an external directory?
+3
source to share
1 answer
You will need to use grunt.task.loadtasks pointing it to the task directory you want to load.
In your case:
grunt.loadTasks('../dev_server/node_modules/grunt-express-server/tasks');
If you check the grunt master on github, on line 325 task.js it needs a task (... / tasks / express.js) file located in the file path you passed as a parameter.
// Load taskfile.
fn = require(path.resolve(filepath))
Edit
If you're wondering if you can move the grunt path to node_modules
, see this question
+6
source to share