I followed this tutorial on installing Grunt on Magento 2. I am running Magento 2.0.7, hosted with one-click app from digitalocean. I only have 'root' user (heard that may cause some problems).
After installing Grunt, the grunt:clean
, grunt:exec
commands work, but it gives error when trying to grunt:less
. Error is:
Loading Gruntfile.js
tasks…ERROR
Error: Cannot find module './jit-grunt'
Warning: Task "less:raultheme" not found. Use –force to continue.
And after using grunt:exec
I cant enter my page anymore, not even backend. It throws this error:
exception 'Magento\Framework\Exception\LocalizedException' with message 'Can't create directory /var/www/html/magento/var/generation/Magento/Framework/App/Response/Http/.' in /var/www/html/magento/vendor/magento/framework/Code/Generator.php:103 Stack trace: #0 /var/www/html/magento/vendor/magento/framework/Code/Generator/Autoloader.php(35): Magento\Framework\Code\Generator->generateClass('Magento\Framewo...') #1 [internal function]: Magento\Framework\Code\Generator\Autoloader->load('Magento\Framewo...') #2 [internal function]: spl_autoload_call('Magento\Framewo...') #3 /var/www/html/magento/vendor/magento/framework/Code/Reader/ClassReader.php(19): ReflectionClass->__construct('Magento\Framewo...') #4 /var/www/html/magento/vendor/magento/framework/ObjectManager/Definition/Runtime.php(44): Magento\Framework\Code\Reader\ClassReader->getConstructor('Magento\Framewo...') #5 /var/www/html/magento/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(71): Magento\Framework\ObjectManager\Definition\Runtime->getParameters('Magento\Framewo...') #6 /var/www/html/magento/vendor/magento/framework/ObjectManager/ObjectManager.php(71): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\Framewo...') #7 /var/www/html/magento/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(236): Magento\Framework\ObjectManager\ObjectManager->get('Magento\Framewo...') #8 /var/www/html/magento/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(53): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\Framewo...', NULL, 'response', 'Magento\Framewo...') #9 /var/www/html/magento/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(82): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\Framewo...', Array, Array) #10 /var/www/html/magento/vendor/magento/framework/ObjectManager/ObjectManager.php(57): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\Framewo...', Array) #11 /var/www/html/magento/vendor/magento/framework/App/Bootstrap.php(233): Magento\Framework\ObjectManager\ObjectManager->create('Magento\Framewo...', Array) #12 /var/www/html/magento/index.php(38): Magento\Framework\App\Bootstrap->createApplication('Magento\Framewo...') #13 {main}
Magento is on developer mode. I have no clue anymore what might be wrong…
Best Answer
Neither documentation nor the tutorial you're following mentions that you need to rename
package.json.sample
andGruntfile.js.sample
topackage.json
andGruntfile.js
respectively. Rename these two files and runnpm install
andnpm update
.Make sure you have grunt installed globally as stated in the documentation/tutorial. Don't forget to remove your previously installed
package.json
andnode_modules
.Please read the documentation: http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/css-topics/css_debug.html
grunt exec:theme
NOTgrunt:exec