There are a few question on SO about it, but unfortunately they all seem to be deprecated.
Im using angular2 with angular-cli.
To install d3.js im using npm install d3.
My app.component.ts file:
import { Component } from '@angular/core';
import * as d3 from 'd3';
@Component({
selector: 'app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
}
But somehow, the app doesnt load correctly because of error:
Cannot find module 'd3'.
That's kinda strange, especially because the Webstorm is able to see the file and doesn't report any problems.
I also tried to install the c3.js library and after installing ive tried the same import way:
npm install c3
and
import * as c3 from 'c3';
But it doesnt work aswell as the first one.
EDIT!
After using commands:
npm install d3 --save
npm install @types/d3 --save-dev
like @Tudor Ciotlos mentioned, Im getting few errors.
[default] C:\Users\node_modules\@types\c3\index.d.ts:28:41 Generic type 'Selection' requires 4 type argument(s). [default] C:\Users\node_modules\@types\c3\index.d.ts:351:56
Module '" C:\Users\node_modules/@types/d3/index"' has no exported member 'Rgb'. [default] C:\Users\node_modules\@types\c3\index.d.ts:355:47
Module '"C:/Users/node_modules/@types/d3/index"' has no exported member 'Rgb'. [default] C:\Users\ode_modules\@types\c3\index.d.ts:833:51
Module '"C:/Users/node_modules/@types/d3/index"' has no exported member 'Rgb'. [default] C:\Users\node_modules\@types\c3\index.d.ts:943:58
Module '"C:/Users/node_modules/@types/d3/index"' has no exported member 'Rgb'.
Anyone knows why Im getting these errors?