1

i have an issue when i execute my Js file. here is my script:

const puppeteer = require('puppeteer');
const url = "https://www.cdiscount.com/informatique/ecrans-informatiques/ecran-pc-gamer-incurve-msi-optix-mag241cvsfr-2/f-10732-9s63ea21t049.html?idOffre=345385285";

(async () => {
    const browser = await puppeteer.launch({ headless: false, args: ['--no-sandbox'] });
   
})()

in my terminal: reject(new Error([ ^ Error: Failed to launch the browser process! [189:189:0427/181045.185226:ERROR:browser_main_loop.cc(1393)] Unable to open X display.

please help me, I have already entered a lot of command lines in the terminal but nothing helps.

  • Hello and welcome to Stack Overflow ! Which browser are you trying to launch ? Which version ? How do you launch your script ? Are you using a virtual machine ? – fdglefevre Apr 27 '21 at 17:35
  • Hello, i'm trying to launch chromium with pepputeer, I'm using node v16.0, I'm on windows 10 with Ubuntu. – Lilian besse Apr 27 '21 at 20:54
  • Do you need to see the browser ? This problem seems related to the fact that you use WSL and it can't find a DISPLAY to display the browser. If you run your script in a Windows terminal instead of WSL it should be easier. – fdglefevre Apr 27 '21 at 21:20
  • yes i would like to see the browser for a test, when I use windows Powershell terminal the command lines doesn't work.. I don't understand where the problem is from, is it my computer ? Puppeteer ? WSL ? – Lilian besse Apr 27 '21 at 22:13
  • You can install nodejs on Windows. If ```node``` is not found maybe you have to configure your ```PATH``` environment variable, see here https://stackoverflow.com/a/27344046/4726998 Try with a simple HelloWorld script first then try to run your script. – fdglefevre Apr 28 '21 at 12:55
  • Yes I install node on Windows and it's working now.. maybe It's not usable with WSL... – Lilian besse Apr 29 '21 at 13:02

0 Answers0