Vue
How to resolve 'Module parse failed Unexpected token' when chartjs cannot be used?
Thank you for your continued support.
This article contains advertisements that help fund our operations.
オススメ本
⇨ Click here for the table of contents for Laravel articles
When trying to use Chartjs in Vue,
npm install chart.js
After running this command, the following error occurred:
ERROR in ./node_modules/chart.js/dist/chart.esm.js Module parse failed: Unexpected token (6813:12)
Damn it!
⇨Recommended video material for Vue + VuetifyConclusion
The version of Chart.js did not match the version of Vue
In my case, since I was using Vue2,
npm install chart.js@2.9.4
worked! Hooray!
Summary
It was a version compatibility issue with npm!
If you have any feedback or find any errors in the article, please DM me on Twitter!
That's all for now!
Please Provide Feedback
We would appreciate your feedback on this article. Feel free to leave a comment on any relevant YouTube video or reach out through the contact form. Thank you!