Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
Can not build svelte-kit static pages based on md files - build error

I am trying to build static sites with svelte-kit using static-adapter, but when I try to build a project the build process end with error showing that md-parser is not present. I am using this parser for parsing md files with page content served from headless cms.

When I run this code in dev mode using node everything works fine, but when I try build it it runs into error.


> Using @sveltejs/adapter-static
TypeError: parseMD is not a function

My code index.json.js file:

import fs from "fs";
import parseMD from "parse-md";

export function get() {
  const fileContents = fs.readFileSync("content/pages/home.md", "utf8");
  const pageData = parseMD(fileContents);
  let body = JSON.stringify(pageData);
  return {body}
}

And there is a index.svelte file:

<script context="module">
  export async function load({ fetch }) {
    const pageData = await fetch(`index.json`).then((r) => r.json());
    console.log(pageData);
    return {
      props: { pageData },
    };
  }
</script>

<script>
  export let pageData;
</script>

<div class="container">
  <h1>{pageData.metadata.text}</h1>
  {pageData.content}
</div>

Can you help me please? How can I parse md files without allowed 3th party lib imports in *.json.js files?

Thank you for any advice.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You probably need to do

import {default as parseMD} from 'parse-md;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!