I have a problem with a script containing Puppeeter when I run it with Parcel. When I launched it with command line, without building with Parcel, it works fine.
My first error was the message : Uncaught SyntaxError:missing = in const declaration
It appears because the variable const PUPPETEER_EXPERIMENTAL_CHROMIUM_MAC_ARM; was not initialized in the index.87e9977b.js file in the dist folder created by Parcel.
So I tried to add the variable to my environment variables, and to npm config file, but it didn't worked, so I just commented the line.
After that I had many other errors showing as in the picture below.

Here is the code of my script WebScrapperPuppeteer.ts. It works when not using Parcel.
const puppeteer = require('puppeteer');
const fs = require('fs');
async function main(){
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto("https://unsplash.com/t/animals", {waitUntil: "domcontentloaded"});
//await page.waitFor(5000);
await page.screenshot({path:'test.png'});
let images = await page.evaluate(()=> {
let img = Array.from(
document.querySelectorAll("img.YVj9w")
).map((image) => image.getAttribute("src"));
return img;
});
console.log(images);
await browser.close();
}
main();
I don't want to change Parcel if possible, because for everything else it is very convenient.
Thanks in advance for your help :)