gajus / puppeteer-proxy

Proxies Puppeteer Page requests.
Other
197 stars 24 forks source link

Cannot use import statement outside a module #10

Closed ordimans closed 4 years ago

ordimans commented 4 years ago

Cannot use the example in the README, to test it.

I am a begginer, so sorry if it's easy, but i didn't understand what i must do ? use MJS if yes how ? or anything else ?

I have this error then i try to use

node proxy.js

import puppeteer from 'puppeteer'; ^^^^^^ SyntaxError: Cannot use import statement outside a module

script :


import puppeteer from 'puppeteer';
import {
  proxyRequest,
} from 'puppeteer-proxy';

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();

  await page.setRequestInterception(true);

  page.on('request', async (request) => {
    await proxyRequest({
      page,
      proxyUrl: 'https://test:1080',
      request,
    });
  });

  await page.goto('http://monip.org');
})();
gajus commented 4 years ago

General Node.js question. Not related to this lib.