Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module parse failed: Unexpected token (567:17) #11375

Open
romanown opened this issue Jun 28, 2023 · 10 comments
Open

Module parse failed: Unexpected token (567:17) #11375

romanown opened this issue Jun 28, 2023 · 10 comments

Comments

@romanown
Copy link

romanown commented Jun 28, 2023

Expected behavior

i create test app on codepen it work. but localy on symfony i have error

Current behavior

after first install by npm and run watch an symfony i have
Module parse failed: Unexpected token (567:17)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
class DatasetController {

static defaults = {};
| static datasetElementType = null;
| static dataElementType = null;

Reproducible sample

can not

Optional extra steps/info to reproduce

No response

Possible solution

No response

Context

No response

chart.js version

4.3.0

Browser name and version

No response

Link to your project

No response

@AndreasZaschka
Copy link

AndreasZaschka commented Jul 4, 2023

Same for Angular Setup with Nx and Cypress

  • Angular 16.x.x
  • Nx 16.x.x
  • Cypress 12.16.0
  • Chartjs 4.3.0
  • webpack 5.x.x
Module parse failed: Unexpected token (567:17)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|     };
| class DatasetController {
>  static defaults = {};
|  static datasetElementType = null;
|  static dataElementType = null;

@romanown
Copy link
Author

romanown commented Jul 4, 2023

I temporarily solved the problem by downgrading the version to 3.9.1. I hope the developers will soon pay attention to this problem and fix it.

@etimberg
Copy link
Member

etimberg commented Jul 4, 2023

@romanown the code that we have is valid JavaScript. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static

I think you need to configure Webpack/Babel per https://stackoverflow.com/questions/64928312/webpack-static-field

@romanown
Copy link
Author

romanown commented Jul 4, 2023

thnks. i use the Symfony and can not configure thw webpack separately

@romanown
Copy link
Author

romanown commented Jul 4, 2023

before I installed this library, everything worked fine. the problem is in this library or in its compatibility, or a newer version of the webpack or babel is needed

@VenkataSuresh7989
Copy link

Currently, I'm using chart.js 3.9.1.I want to upgrade the version 4.3.0 for new features. Getting below error while updating 4.3.0 then run the vue2 project. (https://i.stack.imgur.com/fZHs1.png).Give me proper solution.

@sklinov
Copy link

sklinov commented Oct 25, 2023

Same for
React: 17
Chart.js: 4.4.0
webpack: 4.46.0

@itokun99
Copy link

any update?
still issue in react 18, chartjs v4, in cra

@icleolion
Copy link

For those of you in a position to change your webpack/babel config you'll need to ensure chart.js is pushed through babel-loader and that you are using @babel/plugin-transform-class-properties, either directly or via @babel/preset-env.

@romanown
Copy link
Author

thanks. i use symfony encore with "@babel/plugin-proposal-class-properties": "^7.17.12",
"@babel/preset-react": "^7.17.12",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants