Magento 2 – Fatal Error: Unable to Find Gruntfile

gruntlessmagento2

I have been following a few tutorials to try and get started creating a theme and workflow for Magento 2, and am trying to setup so that I can compile all my LESS files locally, as outlined here.

The problem I am having is running grunt exec:mytheme from the root of my Magento installation. I just receive the following 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.

I have added the neccessary code to the existing dev/tools/grunt/config/themes.js:

mytheme: {
    area: 'frontend',
    name: 'mytheme/default',
    locale: 'en_US',
    files: [
        'css/styles'
    ],
    dsl: 'less'
}

However I am still receiving the missing gruntfile error. Can anyone shed some light on this?

Best Answer

You always need a Gruntfile.js to run grunt (as far as I'm aware) so if you don't have this file in your root directory I'm fairly certain this is the cause of your problem. I think the only purpose of themes.js is to add/remove themes for Grunt.

Do you have Gruntfile.js.sample in your root? You should have looking at the Magento2 repo. Just rename this to Gruntfile.js and try again.

Related Topic