Magento – grunt exec command not working in magento2 – Unable to find local grunt

gruntless-cssmagento2

Today I am trying to execute grunt exec:all and grunt exec commands. Unfortunertly it shown me a error. Earlier it was working fine.
Later I had try to install new Magento 2 setup. Still the error is same:

error preview

I stuck over here.

I tried following with the help of devdocs:

  • re-install nodejs
  • re-install npm
  • re-isntall grunt-cli
  • re-install grunt

Other tools/commands are working fine for grunt like grunt less:luma and at all. Only the issue is into grunt exec.

Can anyone suggest me what is going wrong here? in magento 2?

Best Answer

grunt exec is esentially a shorthand for clearing the folders var/view_preprocessed, var/generation, var/log/system.log and pub/static and running

php bin/magento dev:source-theme:deploy --type=less --locale=en_US --area=frontend --theme=Package/theme

So before running grunt commands you need to make sure that your comand line php is the same as the server php and that it has access to the database.

  1. Make sure that the user with which you are running grunt has access to delete the var and pub/static folders.
  2. Check the permissions on bin/magento and make sure it is a+x (your issue).
  3. Make sure you're running grunt from the folder where the Gruntfile.js is located.
Related Topic