I'm developing a project using Angular CLI.
So I installed tether using npm install tether --save
, and imported the depedency in app.component.ts
using import * as Tether from 'tether'
.
When I try to initialize Tether with new Tether({ ... })
it prints the following error in the console:
EXCEPTION: WEBPACK_IMPORTED_MODULE_4_tether is not a constructor
If I print the Tether variable using console.log(Tether)
it gives me what is seems an empty object.
Could you guys help me? I've never used neither typescript nor webpack before, so I'm sorry if I'm missing something obvious here.
Use
import Tether from 'tether';
This imports the default export of tether which happens to be theTetherClass
you're trying in instantiate.The code
import * as Tether
imports all (default and named) exports of the library, and you'd need tonew Tether.TetherClass()
.Check out the great Exploring ES6 book on modules for details.