Adding JS libraries to Angular 2+

Use npm to install from the project folder,

$ npm install d3 --save

D3.js is a javascript library which needs translations into typescript which angular s written in. So we need,

$ npm install --save @types/d3

In the component file, app.component.ts

import 'd3';

I posted about this before but this is a more straight-forward way to do this.

Leave a Reply