Magento – JS errors Magento 2

javascriptmagento-2.1magento2requirejs

I've been trying to finish something and publish it online this entire weekend, it's some how broken and I have no idea why so I hope someone can help me out.

I've tried adding custom jQuery into my custom theme, with success as jQuery was loaded and the function was working. However! It wasn't functioning properly. For example Safari wouldn't load the jQuery and I kept getting these errors in my console:

defaultCaptcha.js:29 Uncaught TypeError: Cannot read property
'captcha' of undefined authentication-popup.js:26 Uncaught TypeError:
Cannot read property 'autocomplete' of undefined(anonymous function)

I thought it had something to do with the way I declared my jQuery, but when that didn't seem to be the case I decided to remove all of my custom JS, and I still got these errors. Something seems to be broken further up I guess.

My Custom 'Theme' is just a simple landing page with nothing more than I custom subscription box.

What could cause these errors??

Best Answer

Replace in customer module in the file authentication-popup.js:

autocomplete: window.checkout.autocomplete

with:

autocomplete: ((window.checkout && window.checkout.autocomplete) ? window.checkout.autocomplete : null),

Once updated run

php bin/magento setup:static-content:deploy


Update

The issue may be fixed in newer versions: https://github.com/magento/magento2/blob/2.3-develop/app/code/Magento/Customer/view/frontend/web/js/view/authentication-popup.js#L23

autocomplete: window.checkout.autocomplete,

was replaced with:

autocomplete: window.authenticationPopup.autocomplete,

This update is informative and does not provide the complete solution since newer Magento 2 versions come with other changes.

Here is the commit that changed into this: https://github.com/magento/magento2/commit/362f62f3c9b6c2994070615d82efbdf19f15fe50