Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run grunt from a different folder than my root project

Is there a way to tell grunt which grunt.js file to use?

I have an f:\a\b\tools folder that contains grunt.cmd, node.exe,..., my actual web app with GruntFile.js and all the local node_modules is in f:\a\c\my_app

Running grunt from a\c\my_app works fine but trying to run grunt from some other folder say a does not seem to work. I am new to grunt and may be I am missing something obvious.

f:\a>grunt --config c\GruntFile.js 

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

Fatal error: Unable to find local grunt.

If you're seeing this message, either a Gruntfile wasn't found or grunt hasn't been installed locally to your project. For more information about installing and configuring grunt, please see the Getting Started guide:

http://gruntjs.com/getting-started

like image 840
zuniga Avatar asked Feb 14 '13 11:02

zuniga


People also ask

How do I run grunt locally?

Installing grunt-cli locally js method to get started with a project ( npm install && npm test ) then install grunt-cli locally with npm install grunt-cli --save-dev . Then add a script to your package. json to run the associated grunt command: "scripts": { "test": "grunt test" } .


1 Answers

You can set two parameters --base and --gruntfile

From grunt --help:

--base Specify an alternate base path. By default, all file paths are relative to the Gruntfile. (grunt.file.setBase) *

--gruntfile Specify an alternate Gruntfile. By default, grunt looks in the current or parent directories for the nearest Gruntfile.js or Gruntfile.coffee file.

So, you can execute:

grunt --base c\my_app --gruntfile c\my_app\GruntFile.js mytask 
like image 169
Renan Ivo Avatar answered Sep 23 '22 16:09

Renan Ivo