5

I've added a lot of RequireJS code, but know suddenly it does not work anymore. I get an error 'Mismatched anonymous define()' for code that's added from phtml files. This is the code where the error is thrown:

the code where the error is thrown

This is the error is thrown:

error

How can this suddenly not work anymore?

Update

I think there's something completely off with my JS loading. I get different JS errors each time I load the page:

enter image description hereenter image description hereenter image description here

Update 2

Thanks to Siarhey Uchukhlebau I found the answer. The real error was thrown by an external script (Tawk.to, a chat client). This error caused all kind of weird errors. I will investigate this problem further to check if we can isolated these kind of script to prevent them from messing with our main script.

4
  • You can find more info about the "Mismatched anonymous define() modules" error in the requireJS docs Jun 2, 2017 at 11:41
  • Hi Siarhey, thanks for your comment. I know about this part in the documentation. The weird thing is it worked for a long time, and now it does not work anymore. I've implemented the requirejs functions as shown in the documentation.
    – Silvan
    Jun 2, 2017 at 11:43
  • Can you share a link to your dev? Jun 2, 2017 at 11:58
  • I can confirm. If you suddenly see alot of JS errors like mentioned here "Mismatched anonymous define()", please check external scripts loading. I had script from cookiebot.com which were responsible for all the errors.
    – puntable
    Apr 15, 2020 at 12:50

3 Answers 3

7

As I can see in the debug error comes from the online chat script:

https://embed.tawk.to/58f61af6f7bbaa72709c6ddd/default

debug window

First, try to remove it from your store, clean cache and make sure that error has gone, then I'll recommend you contact their support team.

2
  • Siarhey, that's awesome. This solved all of the weird JS errors. I have two questions that you maybe can answer: - How can we debug these errors properly? I see you use the sources tab which I'm known with. But the real error is far away. Is there an easy way to debug this? - Is there a way we can prevent these issues from external scripts? Maybe isolate them or something, to prevent messing with our RequireJS. Thanks again!
    – Silvan
    Jun 2, 2017 at 12:58
  • 1
    @Silvan I just move up on the trace of methods call and come to the source where conditions met (arg[0] is null) , then during inspecting the args I found some info about source class, like specified global variable $_TAWK_. Using google i found script with that variable and found some script on your site: chat widget on your site generates that error. I'll recomend you to start debuging from the line where error was thrown and inspect call-stack trace. PS: Take my apology for my English, i don’t have a good command of it. Jun 2, 2017 at 13:11
0

Recently we have faced the require js issue(Mismatched anonymous define()) on the admin side only. This issue was resolved by disabling the Admin Usage Tracking option to NO.

php bin/magento config:set admin/usage/enabled 0;
php bin/magento cache:clean;

First please check this value of admin/usage/enabled path in the core_config_data table and execute the above Magento commands.

I hope these findings will help others and save time.

Source

1
  • 1
    Had the very same issue just today, after not changing anything in that project for a couple of days. So I assume other people will also have this problem today. Personally I just disabled the "Magento_AdminAnalytics" extension completely. Its a shame that Magento/Adobe would release such a change possibly impacting a large number of vendors and causing huge financial damage due to time invested for figuring out what the issue is. :-(
    – Louis B.
    Jun 16, 2023 at 10:18
0

php bin/magento config:set admin/usage/enabled 0; php bin/magento cache:clean;

@Jitendra Patel, its works for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.