I've installed Magento 2 and set MAGE_MODE=production. However, I'm receiving a lot of JavaScript errors when visiting the home page (requireJS).

I tried flushing the cache and reploying static content files, to no avail.

enter image description here

I'm on the master branch of m2.

3 Answers 3


Generation of anything on the fly, including static content and classes, is prohibited in production mode. Once you enabled production mode and called setup:static-content:deploy it pre-generated everything needed to render the page. I would also recommend to run setup:di:compile and dev:css:deploy.

Alternatively you can run deploy:mode:set: it enables production mode, regenerates everything needed to be regenerated and changes the permissions on the filesystem. Official documentation is here

  • Thanks a ton Eugene. This starts to make sense once you understand how everything works :) Nice suggestion on deploy:mode:set -- will definitely check that out. Sounds like that should be part of a pre-deployment build process when pushing code out to production. Commented Oct 24, 2015 at 19:39

In MAGE_MODE=production static is not materialized at all. So you need run magento setup:static-content:deploy to materialized it. See more detail in official documentation


So, I removed /var/cache, /var/page_cache, and /var/view_preprocessed, then ran ./bin/magento setup:static-content:deploy. Now, everything is rendering correctly.

Does anyone know why this fixed it? The setup:static-content:deploy command also ran a lot faster after this was done.

  • setup:static-content:deploy generated missing files. Or is you question about why removing of var/cache, etc fixed it? Commented Oct 24, 2015 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.