typescript - Using external library with angular cli -
i have installed 1 3rd party module jspdf angular app. module works error in console:
cannot find module '../../../node_modules/jspdf/dist/jspdf.min.js'
.
what did:
- install module via npm:
npm install mrrio/jspdf --save
- import module in component:
import * jspdf '../../../node_modules/jspdf/dist/jspdf.min.js';
- then works module in component.
is missing here?
have @ instructions here: github.com/angular/angular-cli#3rd-party-library-installation.
if jspdf (or other library) needs in global scope, need add js file apps[0].scripts
in angular-cli.json
file, webpack bundles if loaded <script>
tag. if that, can @ adding declare var jspdf: any;
in src/typings.d.ts
or component.
however, looks there typings jspdf npmjs.com/package/@types/jspdf can include after running npm install --save-dev @types/jspdf
; should able import { jspdf } 'jspdf';
in component.
Comments
Post a Comment