木偶:无法启动浏览器进程!产卵 [英] Puppeteer: Failed to launch the browser process! spawn
问题描述
当我尝试运行node app.js
时,出现错误:
该消息无法启动浏览器进程!产卵 /Users/iliebogdanbarbulescu/Downloads/firstProject/node_modules/chromium/lib/chromium/chrome-mac/Chromium.app
访问
我做什么
我在/Users/iliebogdanbarbulescu/Downloads/firstProject/node_modules/chromium/lib/chromium/chrome-mac/Chromium.app
处检查了文件夹,但该文件未压缩.它可以运行.
注意:
如果我尝试在没有路径的情况下执行,它将起作用,但是
我想使用Chrome或Chromium来打开一个新页面.
const browser = await puppeteer.launch({headless:false'});
const express = require('express');
const puppeteer = require('puppeteer');
const app = express();
(async () => {
const browser = await puppeteer.launch({headless:false, executablePath:'/Users/iliebogdanbarbulescu/Downloads/firstProject/node_modules/chromium/lib/chromium/chrome-mac/Chromium.app'});
const page = await browser.newPage();
await page.goto('https://google.com', {waitUntil: 'networkidle2'});
})().catch((error) =>{
console.error("the message is " + error.message);
});
app.listen(3000, function (){
console.log('server started');
})
如果在此确切的浏览器中导航到chrome://version/
页面,它将显示Executable Path
,这是您需要用作executablePath
的确切字符串.操纵launch启动选项.
通常,chrome的路径在MAC上看起来像这样:
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
如果铬位于node_modules
文件夹中,则类似这样:
/Users/iliebogdanbarbulescu/Downloads/firstProject/node_modules/chromium/lib/chromium/chrome-mac/Chromium.app/Contents/MacOS/Chromium
现在,如果您比较用于executablePath
的字符串:它不同于上述方法检索到的字符串. 确切地,应将/Contents/MacOS/Chromium
添加到当前路径的末尾以使其起作用.
注意:与puppeteer捆绑在一起的铬是可与实际pptr版本一起使用的版本:如果您打算使用其他基于chrome/或chrome的浏览器,则可能会遇到意想不到的问题.>
When I try to run node app.js
, I get error:
the message is Failed to launch the browser process! spawn /Users/iliebogdanbarbulescu/Downloads/firstProject/node_modules/chromium/lib/chromium/chrome-mac/Chromium.app
EACCES
What I did
I checked the folder at /Users/iliebogdanbarbulescu/Downloads/firstProject/node_modules/chromium/lib/chromium/chrome-mac/Chromium.app
and the file is not zipped. It can be run.
Note:
If I try to execute without the path, it works, but
I would like to use either Chrome or Chromium to open a new page.
const browser = await puppeteer.launch({headless:false'});
const express = require('express');
const puppeteer = require('puppeteer');
const app = express();
(async () => {
const browser = await puppeteer.launch({headless:false, executablePath:'/Users/iliebogdanbarbulescu/Downloads/firstProject/node_modules/chromium/lib/chromium/chrome-mac/Chromium.app'});
const page = await browser.newPage();
await page.goto('https://google.com', {waitUntil: 'networkidle2'});
})().catch((error) =>{
console.error("the message is " + error.message);
});
app.listen(3000, function (){
console.log('server started');
})
If you navigate to chrome://version/
page in this exact browser, it will show the Executable Path
which is the exact string you need to use as executablePath
puppeteer launch option.
Usually chrome's path looks like this on MAC:
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
Or something like this if chromium is located in your node_modules
folder:
/Users/iliebogdanbarbulescu/Downloads/firstProject/node_modules/chromium/lib/chromium/chrome-mac/Chromium.app/Contents/MacOS/Chromium
Now if you compare the string you used for executablePath
: it differs from the one retrieved with the method mentioned above. Exactly the /Contents/MacOS/Chromium
should be added to the end of the current path to make it work.
Note: the chromium bundled with puppeteer is the version garateed to work together with the actual pptr version: if you plan to use other chrome/or chromium based browsers you might experience unexpected issues.
这篇关于木偶:无法启动浏览器进程!产卵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!