Hi I'm trying to install Grunt on Windows 7 64 bit. I have installed Grunt using commands
npm install -g grunt
npm install -g grunt-cli
but now if I try to do grunt init
, it is throwing me an error -
A valid Gruntfile could not be found. Please see the getting started guide for more information on how to configure grunt: http://gruntjs.com/getting-started Fatal error: Unable to find Gruntfile.
But when I look inside the grunt folder on my system the Gruntfile.js
is there. can someone please guide me how to install this grunt properly and how to write built Script using the grunt. I have one HTML page and java script if i wants built a script using Grunt how can i do it?
To setup GruntJS build here is the steps:
Make sure you have setup your
package.json
or setup new one:Install Grunt CLI as global:
Install Grunt in your local project:
Install any Grunt Module you may need in your build process. Just for sake of this sample I will add Concat module for combining files together:
Now you need to setup your
Gruntfile.js
which will describe your build process. For this sample I just combine two JS filesfile1.js
andfile2.js
in thejs
folder and generateapp.js
:Now you'll be ready to run your build process by following command:
I hope this give you an idea how to work with GruntJS build.
NOTE:
You can use
grunt-init
for creatingGruntfile.js
if you want wizard-based creation instead of raw coding for step 5.To do so, please follow these steps:
For Windows users: If you are using cmd.exe you need to change
~/.grunt-init/gruntfile
to%USERPROFILE%\.grunt-init\
. PowerShell will recognize the~
correctly.Some time we need to set PATH variable for WINDOWS
After that test with
where grunt
Note: Do not forget to close the command prompt window and reopen it.
I got the same issue, but i solved it with changing my Grunt.js to Gruntfile.js Check your file name before typing grunt.cmd on windows cmd (if you're using windows).