Magento 2 – Fix Script Errors When Running MAGE_MODE=production

magento2requirejs

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.

Best Answer

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

Related Topic