Roots Discourse

Gruntfile on xampp localhost

Hi, I noticed when using gruntfile we need a terminal such as putty. Can we use gruntfile on our xampp localhost test site?

So you’re using Windows? Use cmd.exe (Start > Run > cmd)

After you’ve installed node.js you should be able to type npm from cmd, so then you can do npm install -g grunt-cli to install Grunt globally and then run npm install from the theme root directory (cd C:\path\to\wp-content\themes\roots\)

I run my local dev box with Xampp and it works perfect inside of command line - just like Ben said above. You need to install grunt, and then grunt modules, inside of your working htdocs directory. For example htdocs/test.

Be sure you install the required contrib modules for grunt to work inside your working directory.,

npm install grunt-contrib-clean …

grunt.loadNpmTasks(‘grunt-contrib-clean’);
grunt.loadNpmTasks(‘grunt-contrib-jshint’);
grunt.loadNpmTasks(‘grunt-contrib-uglify’);
grunt.loadNpmTasks(‘grunt-contrib-watch’);
grunt.loadNpmTasks(‘grunt-recess’);

Thank you for your responses. I managed to install node.js over my windows 7 and type the commands. It worked!

I have a follow up question on using grunt with xampp. Is there a command line to restart grunt? or perhaps refresh it?

grunt - is to run the task once
grunt watch - is to run the task automatically when something has changed

What you can do is the following:

CTRL + C to abort grunt watch (then type whatever it says yes confirm, depending on your Language)

restart it by typing again “grunt watch”

You might have to do this once you have made or want to make changes to the _main.js file, as it won’t run without errors. Abort grunt watch before you make changes then run grunt, then grunt watch again.

It works though, but would be interested if there is a nicer solution to this.

Hello master, I have problem about instalation Grunt,
for the moment Install grunt-cli globally with npm install -g grunt-cli. succes but if I install npm install not work, I have error in CMD npm is not recodnized
this my script in CMD : C:\xampp\htdocs\kesrabatu\wp-content-\themes\kesrabatu>npm install

my path : C:\Program Files (x86)\nodejs;C:\Users\Gharizah\AppData\Roaming\npm

thanks :slight_smile:

and now this my error
please help me

The first line says that Git is not installed. That’s your issue.

I’ve installed the GIT but still error

Run this: node node_modules/bower/bin/bower install

and come back with the message you get.

For me it was Bower that wasn’t installed correctly because of permissions, so I ran: bower install -g --allow-root

After in my Roots theme directory I ran npm install.

Hope that will help you

Use Git Bash and run the command again.