I have used npm to install angular-plotly.js according to its documentation (https://github.com/plotly/angular-plotly.js/blob/master/README.md) as follows:
npm install angular-plotly.js plotly.js-dist-min --save
npm install @types/plotly.js-dist-min --save-dev
When I go into my main app component, I include the following code:
import { NgModule } from '@angular/core';
...
import * as PlotlyJS from 'plotly.js-dist-min';
import { PlotlyModule } from 'angular-plotly.js';
PlotlyModule.plotlyjs = PlotlyJS;
@NgModule({
declarations: [
AppComponent,
...
],
imports: [
...,
PlotlyModule
],
providers: [
...
],
bootstrap: [AppComponent],
})
export class AppModule { }
Now, when I ng serve --open my app (which is Angular 13.x), I get the following errors:
core.mjs:4032 JIT compilation failed for NgModule class AppModule {
}
getCompilerFacade @ core.mjs:4032
get @ core.mjs:23727
getNgModuleDef @ core.mjs:1128
assertNgModuleType @ core.mjs:1297
compileNgModuleFactory @ core.mjs:25796
bootstrapModule @ core.mjs:26047
14431 @ main.ts:11
__webpack_require__ @ bootstrap:19
__webpack_exec__ @ main.ts:12
(anonymous) @ main.ts:12
__webpack_require__.O @ chunk loaded:23
(anonymous) @ main.ts:12
webpackJsonpCallback @ jsonp chunk loading:71
(anonymous) @ main.js:2
core.mjs:4051 Uncaught Error: The NgModule 'AppModule' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available.
JIT compilation is discouraged for production use-cases! Consider using AOT mode instead.
Alternatively, the JIT compiler should be loaded by bootstrapping using '@angular/platform-browser-dynamic' or '@angular/platform-server',
or manually provide the compiler with 'import "@angular/compiler";' before bootstrapping.
at getCompilerFacade (core.mjs:4051:1)
at AppModule.get (core.mjs:23727:1)
at getNgModuleDef (core.mjs:1128:1)
at assertNgModuleType (core.mjs:1297:1)
at compileNgModuleFactory (core.mjs:25796:1)
at PlatformRef.bootstrapModule (core.mjs:26047:1)
at 14431 (main.ts:11:26)
at __webpack_require__ (bootstrap:19:1)
at __webpack_exec__ (main.ts:12:37)
at main.ts:12:37
Thus far I have been able to successfully troubleshoot this issue. Does anyone know how to resolve this?