'Chart is not a constructor' when importing as ES6 module
See original GitHub issueAfter installing as a npm module (npm install frappe-charts
), I’m unable to import a constructor.
Docs says to import like this:
import {Chart} from 'frappe-charts'
…the docs from NPM says to import like this:
import Chart from 'frappe-charts/dist/frappe-charts.min.esm'
Either way it doesn’t work for me.
const chart = new Chart(this.chartWrapper, {...})
results in *.Chart is not a constructor
error.
I’m using Webpack 4 and React 16 (but React shouldn’t have anything to do with this issue).
Frappé Charts version: v1.1.0
Any suggestions? Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:16 (8 by maintainers)
Top Results From Across the Web
webpack imported module is not a constructor - Stack Overflow
For me, this error was caused by importing through index files. I had multiple directories with their index.ts files that exported all the...
Read more >TypeError: "x" is not a constructor - JavaScript - MDN Web Docs
The JavaScript exception "is not a constructor" occurs when there was an attempt to use an object or a variable as a constructor,...
Read more >Module Methods - webpack
This section covers all methods available in code compiled with webpack. When using webpack to bundle your application, you can pick from a...
Read more >TypeError: _gauge2.default is not a constructor - Laracasts
I can see ChartJS I just use import Chart from 'chart.js' ; Somehow it auto-discovers which file it needs. ChartJS is a NPM...
Read more >Using TypeScript or ES6 – amCharts 4 Documentation
import * as am4charts from "@amcharts/amcharts4/charts";. When importing the module, use its npm name @amcharts/amcharts4/... . IMPORTANT. It is ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You need to import the EcmaScript module straight from the dist folder:
cc @deligent-ant @maulerjan @panjizhi
@scmmishra in the next major version, will there just be a hybrid import which combines ESM/CommonJS (like most NPM packages)? This way users can just do:
This would be great, so that developers don’t need to worry about digging into the
/dist/
folder to find the file that they need.