Use npm JavaScript package in Ionic2 TypeScript project

I started my first project with Ionic2 (TypeScript) and need to use the npm JavaScript package. In my project I use https://github.com/huttarichard/instagram-private-api

I don't understand how can I properly import a class instead the require and how I should use values in constructor class.

var Client = require('instagram-private-api').V1;
var device = new Client.Device('someuser');

1 answer

  • answered 2018-01-12 08:27 Dmitry Stepanov

    1. Go to /src/
    2. Open the assets folder
    3. Create a /js/ folder inside assets
    4. Copy your .js inside this js folder
    5. Goto /src/index.html
    6. Add your path Go to your typescript file of choice and declare var N; N.yourFunction

    Greetings