1

I tried to add a main.js to my Magento theme using the answer on How To add JS file in frontend for all pages, however, it caused issues so I removed this, however, I still get console error for this.

Uncaught SyntaxError: Unexpected token } in JSON at position 199
at JSON.parse (<anonymous>)
at getData (http://domain.dev/products/pub/static/version1497885161/frontend/aa/aa-theme/en_US/mage/apply/main.js:51:24)
at Array.map (native)
at HTMLDocument.apply (http://domain.dev/products/pub/static/version1497885161/frontend/aa/aa-theme/en_US/mage/apply/main.js:67:18)
at fire (http://domain.dev/products/pub/static/version1497885161/frontend/aa/aa-theme/en_US/jquery.js:3232:32)
at Object.add [as done] (http://domain.dev/products/pub/static/version1497885161/frontend/aa/aa-theme/en_US/jquery.js:3291:8)
at jQuery.fn.init.jQuery.fn.ready (http://domain.dev/products/pub/static/version1497885161/frontend/aa/aa-theme/en_US/jquery.js:3542:26)
at jQuery.fn.init (http://domain.dev/products/pub/static/version1497885161/frontend/aa/aa-theme/en_US/jquery.js:2967:11)
at jQuery.fn.init (http://domain.dev/products/pub/static/version1497885161/frontend/aa/aa-theme/en_US/jquery/jquery-migrate.js:225:17)
at jQuery (http://domain.dev/products/pub/static/version1497885161/frontend/aa/aa-theme/en_US/jquery.js:75:11)

I've tried to resolve this by removing the contents of pub/static and ran the PHP bin/magento setup:static-content: deploy but the console error still appears and is causing all javascript elements on my Magento site to not work.

  • Just had this myself. My cause was because I left a rogue , at the end of some JSON configuration in one of my templates for a knockout component. – Tom Burman Aug 10 '17 at 16:55
1

Try clearing browser cache if you haven't already, I've had this a few times when I forgot to clear it.

Also make sure you have un-done the steps you took to add it, so remove the related JS from the require JS config to.

|improve this answer|||||
  • Yeah i've cleared both Magento and browser caches. I've completely removed it from the theme but I'm not 100% sure whether this is from the main.js I tried to add or others as I searched the complete site and there are still references to main.js in other 'core?' files. – heady12 Jun 19 '17 at 16:39
0

Remove pub/static folder content and /var/view_processed or php bin/magento setup:upgrade (this remove all static content) ,then deploy

|improve this answer|||||
  • Unfortunately didn't resolve my error :( Do i need to re-run Magento compile command when it asks? – heady12 Jun 19 '17 at 16:02
  • Which thing you have done can you write step – Feedlay Technologies Jun 19 '17 at 16:03
  • Ive tried removing pub/static contents and /var/view_processed/ then ran php bin/magento setup:static-content:deploy. Also tried to run php bin/magento setup:upgrade, but didn't run the compile command when it asked, just ran php bin/magento setup:static-content:deploy. I then cleared cache by php bin/magento cache:flush but error still showing. – heady12 Jun 19 '17 at 16:09
  • Just tired this again and ran the compile command when it asks, but still no luck :( – heady12 Jun 19 '17 at 16:13
  • 1) remove var/view_processed – Feedlay Technologies Jun 19 '17 at 16:15

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.