Magento – Uncaught SyntaxError: Unexpected token } in JSON at position 199

consolefatal errorjavascriptmagento2requirejs

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.

Best Answer

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.

Related Topic