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

186
Views
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 answers
Answer question

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