I have installed grunt
and grunt-cli
globally using sudo npm install -g grunt...
commands.
My working folder is `/opt/web’, please don’t ask why 🙂
Checking grunt version inside `/opt/web’ works:
$ grunt --version grunt-cli v0.1.13
However, I can’t actually run a grunt task from there:
$ grunt grunt-cli: The grunt command line interface. (v0.1.13) 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.
If I install grunt locally, it then asks to install all it’s dependencies locally (that are already installed globally (!)).
This behavior seems strange to me.
My question is:
Is this a bug or a feature? Is this by design that grunt wants to work with locally installed things only?
Advertisement
Answer
This is by design. See the grunt-cli readme.
The cli doesn’t do anything except find and run a local copy of grunt.
This means that each project can use a version of grunt that the project specifies and is know/tested to work correctly. Given the number of critical things grunt can do, this compatibility promise is a big deal.
There is also a good blog post on the node site that talks a bit more about module installation locations.