Topic: A script error occurred.

Lee HoLim priority asked 7 months ago


chart.mjs:8439 Uncaught TypeError: Cannot set properties of undefined (setting 'Constructor') at HTMLDocument. (chart.mjs:8439:22)

enter image description here

Expected behavior

Actual behavior

Resources (screenshots, code snippets etc.)


Lee HoLim priority answered 7 months ago


<script type="text/javascript" src="https://www.mysite.com/js/mdb.umd.min.js"></script>

When you load line 1 of the script, you get the error below.


Uncaught TypeError: Cannot set properties of undefined (setting 'Constructor') at HTMLDocument. (index.js:229:14)

index.js:229

js/mdb/util/index.js This is the 229 line in this file.

enter image description here

I downloaded and tested the MDB Standard PRO 7.1.0 version and got the same error on every page. In the 7.0.0 version, I was getting a chart related error, but in the 7.1.0 version, I no longer get the error.


Kamila Pieńkowska staff commented 7 months ago

Can you for test purposes not preload our JS but import it only at the end of the body? It seems to be causing the error you get.


Lee HoLim priority commented 7 months ago

After spending a day digging into the code, I realized that something was wrong with the migration code. Thanks for your response.

For now, everything is working fine.


DashMarketingGroup priority answered 7 months ago


I think the issue is very simple. EVERY SINGLE PAGE I load shows the same error about chart.js in the developer console of the browser. I don't use the chart component, and I only reference 2 files in my code:

<script type="text/javascript" src="../js/mdb.umd.min.js"></script>
<script type="text/javascript" src="../plugins/js/all.min.js"></script>

There is something wrong with your chart component, obviously. It doesn't keep code from executing, but it is annoying to have console errors.


Kamila Pieńkowska staff commented 7 months ago

I cannot replicate this bug you have in your project setup.

Please prepare a simple mock repo without MDB files (we will import them) that will replicate this error because I cannot resolve the error I do not have.


DashMarketingGroup priority answered 7 months ago


The error mentioned in this post comes up in the browser console for EVERY page my site loads, even when I am not using the chart compoent:

chart.mjs:8439 Uncaught TypeError: Cannot set properties of undefined (setting 'Constructor') at HTMLDocument. (chart.mjs:8439:22)

The new version (7.0) is VERY frustrating, because it requires a complete refactor of code to ensure code that was working just fine in version 6.4.2 will continue to work in 7.0. I am deeply disappointed with this new version, and have lost a lot of time trying to make things work again that were just fine before migrating to 7.0.


Lee HoLim priority answered 7 months ago


I use the MDB PRO Standard version. I am migrating from version 6.4.2 to version 7.0.0.

It simply loads the mdb.umd.min.js file and does nothing.

If I access the site below with a chrome browser and press F12 to check the console log in Dev Tool, I get a script error.

https://d-en.vivoldi.com

I can fix the 404 error because it's currently migrating, but the script error is beyond my control.


Kamila Pieńkowska staff commented 7 months ago

This is an error of chart.js, not mdb. But please change the version of Chart.js to 3.7.1 and let me know if it helped.


Lee HoLim priority commented 7 months ago

I only loaded the mdb.umd.min.js file in the MDB Standard PRO version. Not ES. Why am I getting an error on chart.mjs that I don't even use?


Lee HoLim priority commented 7 months ago

We hope to fix this error in 7.0.1 as soon as possible.


Kamila Pieńkowska staff commented 7 months ago

You have chart.js in your dependencies in node_modules Please remove folder node_modules and run npm install


Kamila Pieńkowska staff commented 7 months ago

Also, make sure that you do not have chart.js in your package.json


Lee HoLim priority commented 7 months ago

I don't know how to do node.js. I can only handle html and jquery. I use some chart components in my webpage. I get both errors with and without the chart component. When can I download the bugfixed mdb.umd.min.js file?


Kamila Pieńkowska staff answered 7 months ago


I'm sorry but can you explain what is the problem and describe the situation in which it occurs and create a snippet that recreates the problem?

I need to replicate the problem to help you troubleshoot.


Lee HoLim priority commented 7 months ago

I use the MDB PRO Standard version. I am migrating from version 6.4.2 to version 7.0.0.

It simply loads the mdb.umd.min.js file and does nothing.

If I access the site below with a chrome browser and press F12 to check the console log in Dev Tool, I get a script error.

https://d-en.vivoldi.com

I can fix the 404 error because it's currently migrating, but the script error is beyond my control.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 7.0.0
  • Device: Desktop
  • Browser: Chrome 119.0.6045.159
  • OS: Mac OS 14.1.1
  • Provided sample code: No
  • Provided link: No