angular2-markdown package works on localhost but when I deploy on GitHub pages it gives me an error

Issue

Situation

I develop a site with Angular-CLI and will publish that on GitHub pages. the link to my project is https://heinpauwelyn.github.io.

I’ve installed a package named angular2-markdown to render markdown files on my HTML pages. Below you see my code:

<div class="container">
    <div class="row">
        <div class="col-md-8">
            <h2>Internship</h2>
            <!-- Below you see the `markdown` tag to render the markdown file -->
            <markdown path="/reports/intro.md"></markdown>
        </div>
        <div class="col-md-4">
            <app-reportslist></app-reportslist>
        </div>
    </div>
</div>

To test the site on localhost I use this command:

ng serve

This command gives no problem and render the markdown files good.

The problem

An error will be throw when I use command below to deploy my website on GitHub pages.

ng github-pages:deploy

This gives me next error:

ERROR in MarkdownModule is not an NgModule

Here is my code in my app.module.ts:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
 
import { MarkdownModule } from 'angular2-markdown';
import { AppComponent } from './app.component';
 
@NgModule({
    declarations: [AppComponent],
    imports: [
        BrowserModule,
        MarkdownModule
    ],
    bootstrap: [AppComponent],
})
export class AppModule { }

I’ve tried

Attempt one

I know on the guide stands that I must use MarkdownModule.forRoot(). If I use now ng serve, I’ve got this error:

ERROR in Error encountered resolving symbol values statically. Calling function MarkdownModule, function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in C:/***/heinpauwelyn.github.io/src/app/app.module.ts.

ERROR in C:/***/heinpauwelyn.github.io/src/app/app.module.ts: Property forRoot does not exist on type typeof MarkdownModule.

Attempt two

If I comment the line export class AppModule() like in the guide, I got this error:

ERROR in C:/***/heinpauwelyn.github.io/src/main.ts: Module C:/***/heinpauwelyn.github.io/src/app/app.module.ts has no exported member AppModule.

ERROR in C:/***/heinpauwelyn.github.io/src/app/app.module.ts: Declaration expected.

What is normal of course.

Question

How could I solve this problem?

Thanks in advance.

Solution

You are using 1.3.14 please use the latest version. The current version is 1.3.18

npm install angular2-markdown --save

It should fix your issue.

Answered By – Dimpu Aravind Buddha

Answer Checked By – Clifford M. (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.