Shai M. Shai M. - 4 months ago 128
Javascript Question

how to import highcharts with webpack and babel

I use ES6, Babel and webpack stack.

I have installed highcharts by npm (I prefer to use the official highcharts npm repo):

npm install highcharts-release --save


But, regular import (ES6) doesn't work as expected:

import highcharts from 'highcharts';


How can I import Highcharts via webpack import?
Can you post a webpack.config.js example (or other way to config the plugins)?

Thanks.

EDIT

The error is:

Uncaught Error: Cannot find module "highcharts" webpackMissingModule @ review-chart.js:2(anonymous function) ....

Answer

There is a NPM called commonjs-highcharts that solves it. Just run npm i commonjs-highcharts and import it:

import highcharts from "commonjs-highcharts"

Worked for me.

Comments