Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

261
Vistas
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 Respuestas
Responde la pregunta

0

You probably need to do

import {default as parseMD} from 'parse-md;
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda