There are a few questions about this, but unfortunately they all seem outdated.
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 for some reason, the application does not load correctly due to an error: Cannot find module 'd3'.
This is strange, especially because Webstorm is able to see the file and does not report any problems.
I also tried installing the c3.js library and after installing ive tried the same import method:
npm install c3
and
import * as c3 from 'c3';
But it does not work the same as the first.
CHANGE!
After using the commands:
npm install d3 --save
npm install @types/d3 --save-dev
as @Tudor Ciotlos mentioned, Im getting some errors.
[default] C: \ Users \ node_modules \ @types \ c3 \ index.d.ts: 28: 41 General type "Select" requires 4 type arguments (s). [default] C: \ Users \ node_modules \ @types \ c3 \ index.d.ts: 351: 56
The module '' C: \ Users \ node_modules / @ types / d3 / index "'does not have an exported member of' Rgb.” [Default] C: \ Users \ node_modules \ @types \ c3 \ index.d.ts: 355: 47
The module '' C: / Users / node_modules / @ types / d3 / index "'does not have an exported member of' Rgb '. [Default] C: \ Users \ ode_modules \ @types \ c3 \ index.d.ts: 833: 51
The module '' C: / Users / node_modules / @ types / d3 / index "'does not have an exported member of' Rgb.” [Default] C: \ Users \ node_modules \ @types \ c3 \ index.d.ts: 943: 58
Module '' C: / Users / node_modules / @ types / d3 / index "'does not have an exported member of' Rgb '.
Does anyone know why Im getting these errors?