2

我使用备注将 Markdown 转换为 html,但出现错误

备注适用于nodejs

我不知道 angular 或 remark 出错了

请帮忙

这是错误代码

ERROR ReferenceError: process is not defined
    at new VFile (core.js:55)
    at VFile (core.js:49)
    at Function.processSync (index.js:387)
    at AppComponent.ngOnInit (app.component.ts:21)
    at checkAndUpdateDirectiveInline (core.js:31909)
    at checkAndUpdateNodeInline (core.js:44366)
    at checkAndUpdateNode (core.js:44305)
    at debugCheckAndUpdateNode (core.js:45327)
    at debugCheckDirectivesFn (core.js:45270)
    at Object.eval [as updateDirectives] (AppComponent_Host.ngfactory.js? [sm]:1)

这里是 app.component.ts

import { Component, OnInit } from '@angular/core';

import * as remark from 'remark';
import * as html from 'remark-html';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
  htmlDoc: string;
  mdDoc: string;

  constructor() { }

  ngOnInit() {
    console.log(
      remark()
        .use(html)
        .processSync('# hello World').toString()
    );
  }
}
4

0 回答 0