Puppeteer版本: 1.11.0
平台/操作系统版本: Windows 10专业版
Node.js版本: 12.6.6
当我在windows中做本地开发测试时,在executablePath中发生了问题。
“无法启动chrome!spawn /usr/bin/chrome-browser ENOENT”
我看到windows需要获取完整的路径。否则无法找到chrome.exe
代码中的默认值:
const browser = await puppeteer.launch({executablePath: '/path/to/Chrome'});在windows中,它是这样工作的:
const browser = await puppeteer.launch({executablePath: 'C:\\your_workspace\\node_modules\\puppeteer\\.local-chromium\\win64-(version)\\chrome-win\\chrome.exe'});在可视化代码中建议路径
可视化代码视图资源管理器
发布于 2020-06-26 15:49:00
也许这能有所帮助:
const osPlatform = os.platform(); // possible values are: 'darwin', 'freebsd', 'linux', 'sunos' or 'win32'
console.log('Scraper running on platform: ', osPlatform);
let executablePath;
if (/^win/i.test(osPlatform)) {
executablePath = '';
} else if (/^linux/i.test(osPlatform)) {
executablePath = '/usr/bin/google-chrome';
}发布于 2021-03-01 20:32:24
您还可以设置环境变量
..。
这在与
设置为
https://stackoverflow.com/questions/59786319
复制相似问题