0

I'm getting a syntax error while in the function node code editor (red underline squiggles and triangle):

const puppeteer = global.get('puppeteer');

(async () =>
{
  const browser = await puppeteer.launch({executablePath: '/usr/bin/chromium'});
  const page = await browser.newPage();
  await page.goto('http://church.daford.work:58080', { waitUntil: 'networkidle0'});
  await page.type('#password', 'pwd-here');
  await page.click('#loginBtn');
  // @ts-ignore
  const data = await page.evaluate(() => document.querySelector('*').outerHTML);
  console.log(data);
  await browser.close();
})();
Cannot find name 'document'. Do you need to change your target library?
Try changing the 'lib' compiler option to include 'dom'.(2584)

Where do I do this?

UPDATE: I found I can ignore this error with

// @ts-ignore

and the code works, but I would like to know if there is a better way to handle this.

1 Answer 1

1

Where are you running this code? If this is inside a Node-RED Function node, then that code runs inside a node.js environment, not the browser. This means there is no document object to work with.

If this is somewhere else in Node-RED, please update your question with full details.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.