In our case this was a bit of code in a default template which was loading the customer-data.js file after it had already been called on the success page.
We found file: vendor/magento/module-checkout/view/frontend/templates/success.phtml
was loading this code:
<script>
require([
'Magento_Customer/js/customer-data'
], function (customerData) {
var sections = ['cart'];
customerData.invalidate(sections);
customerData.reload(sections, true);
});
</script>
Removing this code fixed it, which we did by creating a copy of this file in our theme templates directory and removing the offending code snippet.
You can use Chrome Dev tools to find out where the error was happening and then just before in that file on your local dev add in a console.trace();
call to establish what was calling the function which is throwing the error in the console. Follow the chain to where you are loading things improperly.
static-content deploy