这是我的代码:
const puppeteer = require('puppeteer');
(async()=>{
const browser = await puppeteer.launch({
executablePath:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
headless:false,
args:['--user-data-dir=/tmp/puppeteer_dev_chrome_profile-CGzsOE/'],
ignoreDefaultArgs: true
})
const page = await browser.newPage()
page.goto("https://www.google.com")
})()
当我运行我的 js 文件时,我收到此错误:
(node:522) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
[14964:4488:0907/043929.675:ERROR:cache_util_win.cc(21)] Unable to move the cache: Access is denied. (0x5)
[14964:4488:0907/043929.675:ERROR:cache_util.cc(139)] Unable to move cache folder C:\Users\dabas\AppData\Local\BraveSoftware\Brave-Browser\User Data\ShaderCache\GPUCache to C:\Users\dabas\AppData\Local\BraveSoftware\Brave-Browser\User Data\ShaderCache\old_GPUCache_000
[14964:4488:0907/043929.675:ERROR:disk_cache.cc(184)] Unable to create cache
[14964:4488:0907/043929.675:ERROR:shader_disk_cache.cc(606)] Shader Cache Creation failed: -2
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at onClose (/mnt/c/Users/dabas/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:193:20)
at ChildProcess.helper_js_1.helper.addEventListener (/mnt/c/Users/dabas/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:184:79)
at ChildProcess.emit (events.js:203:15)
at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
(node:522) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:522) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
和另一个弹出错误说:
Brave cannot read and write to its Data directory
/tmp/puppeteer_dev_chrome_profile-CGzsOE
我真的需要帮助来解决这个问题,我已经尝试了很多东西,比如没有指定数据目录,但没有任何效果。