webpack imported module is not a constructor

后端 未结 2 1995
情书的邮戳
情书的邮戳 2021-02-06 23:42

I created a small JS module which I intend to make an npm package, but for now is just on GitHub. This module is written in ES6 and SCSS, and is thus relying on webpack and babe

2条回答
  •  粉色の甜心
    2021-02-07 00:27

    If you are not the library author and are having a problem consuming another library, you may be seeing an error like this:

    TypeError: [LIBRARY_NAME]__WEBPACK_IMPORTED_MODULE_3__ is not a constructor
    

    If that's the case, you may be importing the library incorrectly in your code (it may be a problem with default exports). Double check the library docs for usage.

    It may be as simple as changing this:

    import Foo from 'some-library/Foo';
    

    to this:

    import { Foo } from 'some-library';
    

提交回复
热议问题