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

191
Visualizações
fs.writeFileSync Can't set DOCTYPE here

This Meteor code uses fs.writeFileSync to save a file to disc with the html extension, it saves the file OK but I get the following server error

While processing files with templating-compiler (for target web.browser): screen_shots/page.html:1: Can't set DOCTYPE here. (Meteor sets for you)

And the following browser console message

Uncaught SyntaxError: Unexpected token < in JSON at position 1

Any idea how to fix this error? Thanks

import { Meteor } from 'meteor/meteor';
const puppeteer = require('puppeteer'); //maybe change const to let
const fs = require('fs')
//.... SOME CODE HERE...
let searchLink = await page.$('input[alt="Search"]')
await searchLink.click()

await page.waitForNavigation()
const html = await page.content()
fs.writeFileSync("/screen_shots/page.html", html, 'utf8') //removing utf8 did not eleminate the error

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The location of /screen_shots/page.html is in your source tree, which causes Meteor to start rebuilding, and abort what it's doing. You definitely don't want this. Meteor watches all source files that are explicitly imported, but also anything in client and server folders.

When running meteor or meteor run in this mode, all files excepted of those in the folder /imports are loaded automatically. There are also a few other rules to it, all can be found on this page: https://guide.meteor.com/structure.html#load-order

There is more information here: https://stackoverflow.com/a/64116026/517914

The .png files you also wrote in the same folder will also be loaded automatically, but won't cause errors.

You probably don't write to the file system

Now that you understand what's going on, you may want to avoid writing to the file system. There are a few reasons for this

  1. When using docker, the local file system is read only by default
  2. You can attach a volume, but you need to attach it to each server in your scaling group
  3. Volumes get full
  4. S3 (or similar) is more convenient, and you can apply policies and permissions to the files
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