I have tried my .js project with Chromium but it was very slow rather than Chrome's itself. So i decided running my program with Chrome on VS Code but this time VS Code created a file named launch.json and i couldn't achieve to bind index.js to launch.json.
Summary of my question, how can i run my script in Chrome on VS Code? What should i do to run launch.json and index.js together? I will leave my code blocks now.
launch.json:
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "url",
"webRoot": "${workspaceFolder}"
}
]
}
index.js:
const puppeteer = require('puppeteer')
const fs = require('fs/promises')
async function start() {
const browser = await puppeteer.launch({headless: false})
const page = await browser.newPage()
await page.waitForSelector('selector')
await browser.close()
}
start()
I didn't try anything essentially, because i don't know about solution. I researched on Google, Stackoverflow and Youtube too many times (2 days at least, maybe i can't find keyword because of my poor English) I described my problem as much as i can.
I must add, executablePath solution didn't work for me and
" crbug/1173575, non-JS module files deprecated. " this error message appears on my debbugging console.
thx
CodePudding user response:
Running program with Windows PowerShell is solution. The code that i execute:
const puppeteer = require('puppeteer')
const fs = require('fs/promises')
async function start() {
const browser = await puppeteer.launch( { headless: false,
executablePath: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' })
const page = await browser.newPage()
await page.waitForSelector('selector')
await browser.close()
}
start()
So yes, executablePath is a solution, if you don't try that on VS Code.