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

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

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 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