简体   繁体   中英

Cannot find module '@angular/core

I want to implement chart in my angular app. So I used ChartJs. I implemented method to show chart but problem in its gives an error when compiling. 它说我在 ../node_modules/ng2-charts/lib/base-chart.directive.d.ts 中有错误

My base-chart.directive.d.ts file as follows.

 import { OnDestroy, OnChanges, OnInit, EventEmitter, ElementRef, SimpleChanges, DoCheck } from '@angular/core'; import * as chartJs from 'chart.js'; import { Color } from './color'; import { ThemeService } from './theme.service'; export declare type SingleDataSet = (number[] | chartJs.ChartPoint[]); export declare type MultiDataSet = (number[] | chartJs.ChartPoint[])[]; export declare type SingleOrMultiDataSet = SingleDataSet | MultiDataSet; export declare type PluginServiceGlobalRegistrationAndOptions = chartJs.PluginServiceGlobalRegistration & chartJs.PluginServiceRegistrationOptions; export declare type SingleLineLabel = string; export declare type MultiLineLabel = string[]; export declare type Label = SingleLineLabel | MultiLineLabel; export declare class BaseChartDirective implements OnDestroy, OnChanges, OnInit, OnDestroy, DoCheck { private element; private themeService; data: SingleOrMultiDataSet; datasets: chartJs.ChartDataSets[]; labels: Label[]; options: chartJs.ChartOptions; chartType: chartJs.ChartType; colors: Color[]; legend: boolean; plugins: PluginServiceGlobalRegistrationAndOptions[]; chartClick: EventEmitter<{ event?: MouseEvent; active?: {}[]; }>; chartHover: EventEmitter<{ event: MouseEvent; active: {}[]; }>; ctx: string; chart: Chart; private old; private subs; /** * Register a plugin. */ static registerPlugin(plugin: PluginServiceGlobalRegistrationAndOptions): void; static unregisterPlugin(plugin: PluginServiceGlobalRegistrationAndOptions): void; constructor(element: ElementRef, themeService: ThemeService); ngOnInit(): void; private themeChanged; ngDoCheck(): void; copyLabel(a: Label): Label; labelsEqual(a: Label, b: Label): boolean; copyColor(a: Color): Color; colorsEqual(a: Color, b: Color): boolean; updateColors(): void; ngOnChanges(changes: SimpleChanges): void; ngOnDestroy(): void; update(duration?: any, lazy?: any): {}; hideDataset(index: number, hidden: boolean): void; isDatasetHidden(index: number): boolean; toBase64Image(): string; getChartConfiguration(): chartJs.ChartConfiguration; getChartBuilder(ctx: string): Chart; smartMerge(options: any, overrides: any, level?: number): any; private isMultiLineLabel; private joinLabel; private propagateDatasetsToData; private propagateDataToDatasets; private isMultiDataSet; private getDatasets; private refresh; }

在此处输入图片说明

I have already followed instruction which mentioned here But my problem as it is. Please help. My ChartJs version is:ng2-charts@2.2.3 and angular version 8.

尝试npm cache clean --force然后运行npm install ng2-charts@2.3.2 --save重新安装 ng chart。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM