Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

266
Visualizações
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 Respostas
Responde à pergunta

0

You probably need to do

import {default as parseMD} from 'parse-md;
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda