Search code examples
javascriptreactjshowler.js

React error Uncaught TypeError: _howler2.default is not a constructor


I am attempting to import Howler.js into a small React app. I've installed Howler.js in my node_modules with npm install howler --save-dev. In my app.js I import it with

import Howler from 'howler';

But then when I attempt to instantiate it with

let sound = new Howler({
    src: ['test.mp3']
});

I get the following error:

Uncaught TypeError: _howler2.default is not a constructor

I know there are wrappers for react (e.g. this one) but I'd like to get it working without if possible.


Solution

  • That package has a UMD bundle and is setting exports.Howler so you need to do

    import { Howler } from 'howler'