I've made some research on the Web and SOF, but found nothing really helpful on that error.
I installed Node and Puppeteer with Windows 10 Ubuntu Bash, but didn't manage to make it work, yet I manage to make it work on Windows without Bash on an other machine.
My command is :
node index.js
My index.js tries to take a screenshot of a page :
const puppeteer = require('puppeteer');
async function run() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://github.com');
await page.screenshot({ path: 'screenshots/github.png' });
browser.close();
}
run();
Does anybody know the way I could fix this "Error: kill ESRCH" error?
I worked around it by softlinking chrome.exe to node_modules/puppeteer/.../chrome as below
I had the same issue, this worked for me. Try updating your script to the following:
If you want to read all the details on this, this ticket has them (or links to them). https://github.com/Microsoft/WSL/issues/648
Other puppeteer users with similar issues: https://github.com/GoogleChrome/puppeteer/issues/290#issuecomment-322851507
I just fixed this issue. What you need to do is the following:
1) Install Debian dependencies
You can find them in this doc: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
sudo apt-get install
all of those bad boys.2) Add
'--no-sandbox'
flag when launching puppeteer3) Make sure your windows 10 is up to date. I was missing an important update that allowed you to launch Chrome.
Points no consider:
Windows bash is not a complete drop-in replacement for Ubuntu bash (yet). There are many cases where different GUI based apps did not work properly. Also, the script might be confused by bash on windows 10. It could think that the os is linux instead of windows.
Windows 10 bash only supports 64-bit binaries, so make sure the node and the chrome version that's used inside is pretty much 64-bit. Puppeteer is using
-child.pid
to kill the child processes instead ofchild.pid
on windows version. Make sure puppeteer is not getting confused by all these bash/windows thing.Back to your case.
You are using
browser.close()
in the function, but it should beawait browser.close()
, otherwise it's not executing in proper order.Also, You should try to add
await page.close();
beforebrowser.close();
.So the code should be,