gpt4 book ai didi

angularjs - 为什么引用本地(非导出)符号 'require' 错误?

转载 作者:行者123 更新时间:2023-12-05 07:34:14 25 4
gpt4 key购买 nike

我从这里尝试了很多解决方案,但仍然显示此错误

ERROR in Error encountered resolving symbol values statically. Reference to a local (non-exported) symbol 'require'. Consider exporting the symbol (position 8:13 in the original .ts file), resolving symbol AppModule in C:/Users/Bristy/Documents/realtime_chart/client/src/app/app.module.ts

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! live-chart@0.0.0 build: ng build

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the live-chart@0.0.0 build script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm ERR!
C:\Users\Bristy\AppData\Roaming\npm-cache_logs\2018-05-09T17_11_42_862Z-debug.log Done.

这是我的 app.module.ts

import { BrowserModule } from '@angular/platform-browser';

import { NgModule } from '@angular/core';

import { FormsModule } from '@angular/forms';

import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';

import { ChartModule } from 'angular2-highcharts/index';

import { HighchartsStatic } from 'angular2-highcharts/dist/HighchartsService';

declare var require: any;



export function highchartsFactory() {

const hc = require('highcharts');

const dd = require('highcharts/modules/drilldown');

dd(hc);


return hc;

}


@NgModule({

declarations: [

AppComponent

],

imports: [

BrowserModule,

FormsModule,

HttpModule,

ChartModule.forRoot(require('highcharts/highstock')),

],

providers: [ {

provide: HighchartsStatic,

useFactory: highchartsFactory

}],

bootstrap: [AppComponent]

})

export class AppModule { }

最佳答案

试试这个。

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';

import { ChartModule } from 'angular2-highcharts';
import { HighchartsStatic } from 'angular2-highcharts/dist/HighchartsService';

declare var require: any;

export function highchartsFactory() {
const hc = require('highcharts/highstock');
const dd = require('highcharts/modules/exporting');
dd(hc);
return hc;
}



@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
ChartModule.forRoot(require('highcharts/highstock')),
],
providers: [
{
provide: HighchartsStatic,
useFactory: highchartsFactory
}
],
bootstrap: [AppComponent]
})
export class AppModule { }

关于angularjs - 为什么引用本地(非导出)符号 'require' 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50258753/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com