简体   繁体   中英

node.js win10 puppeteer executablePath string

I am on windows 10 command prompt with a node.js project that is supposed to use puppeteer to launch chrome and then do some other web crawling things. I have run npm install for this project, but when I run it with node app.js , I get an error for 'ERROR: The process "chrome.exe" not found.', my puppeteer code inits the browser like this:

    let args = ["--lang=en-US,en", '--no-sandbox', '--disable-setuid-sandbox', '--disable-extensions']
    var exPath = "C:\\Users\\marti\\Downloads\\chrome-win\\chrome-win\\chrome.exe"
    var options = {
        executablePath: exPath,
        headless: false,
        args
    };

In a different command prompt window if i run start C:\\Users\\marti\\Downloads\\chrome-win\\chrome-win\\chrome.exe it will open a chromium window perfectly fine. Is there an arg I might be missing for node.js windows 10 command prompt puppeteer?

Your request should be an asynchronous:

const browser = await puppeteer.launch({
    executablePath: "C:\\Users\\marti\\Downloads\\chrome-win\\chrome-win\\chrome.exe",
    headless: false,
    args: ["--lang=en-US,en", '--no-sandbox', '--disable-setuid-sandbox', '--disable-extensions']
});

And the function in which you are using puppeteer should be of type async function

If the issue still persists try adding '--disable-dev-shm-usage' argument to args.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM