Importing external libraries


#1

I’m building a new app with Ionic2 rc1 and I’m having trouble using a couple external libraries as described here:

I’ve installed them like this:

npm install fabric --save
npm install ckeditor --save

I’ve also installed the types:

npm install @types/fabric --save npm install @types/ckeditor --save

However, when I try to import them in a page, I get two different types of errors:

import { fabric } from "fabric"; //Module '"fabric"' has no exported member 'fabric'. import { ckeditor } from "ckeditor"; //File '<path>/node_modules/@types/ckeditor/index.d.ts' is not a module.

For Fabric, I see the export is declared in the @types/fabric/index.d.ts file:

declare module "fabric" {
  export = fabric;
}

For CKEditor, it seems to be looking in the @types definitions for a module, though this file only declares a namespace:

declare namespace CKEDITOR {...

Including these external libraries seems like it should be a trivial task… What am I missing?


Importing trackingjs third party library
#2

Turns out the import statement just needs to be:

import 'fabric';


#3

Thanks, it works for me with the trackingjs library (https://www.npmjs.com/package/tracking).

But did you find out why it works like that?


#4

try this
import * as fabric from ‘where-the-library-js-is’