14

I wonder if it's possible to run grunt 0.4.* without having installed grunt-cli.

I understand that grunt-cli looks for the version of grunt installed in node-modules in my project directory in order to run that version of grunt but...is it possible to run grunt without having grunt-cli installed? How?

Thanks in advance!

2
  • 1
    The real question here is, why you want to do it? Feb 20, 2013 at 14:27
  • 1
    Hi! Thanks for ask. I think of two cases: One is running grunt from an automated script and the second is having the whole system checked-in in the repository, for ease of installing. Another case could be not having admin permissions to install a package globally.
    – cromandini
    Feb 21, 2013 at 0:42

3 Answers 3

26

The grunt-cli is a very small amount of code. If I was you I would look through it in the GitHub repository. That way you will learn what it does, and it's very easy to do the same.

I have had luck with running it with no grunt-cli. You can do it with the following command:

node -e "require('grunt').cli()"

If you want to specify tasks you can do it like this:

node -e "var g = require('grunt'); g.cli.tasks = ['default']; g.cli()"
2
  • Yeah!! Thank you Allan, your code didn't work on my mac, but going into REPL and running require('grunt').cli(); worked in the command line. And putting the same line of code in a script also worked :)
    – cromandini
    Feb 21, 2013 at 23:52
  • How would you target a specific task with this? ex. grunt default? Nov 21, 2013 at 22:40
15

try

node -e "require('grunt').cli();" 

if you're on a mac / unix

0
0

You can try from some other script:

var grunt = require('grunt');
grunt.cli();

That will look for the grunt package and execute the Gruntfile.js.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.