1

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.

4

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. – Mark Shust at M.academy Oct 24 '15 at 19:39
4

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

0

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? – Eugene Tulika Oct 24 '15 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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