我创建了一个whatsapp bot
,它使用openai
、whatsapp-web.js
和nodejs
。
当deploying
在vercel
上运行时,我面临以下问题:
Error: Failed to launch the browser process!
[0212/144729.058867:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported.
以下是我在deployment
上获得的output
:
Running build in Washington, D.C., USA (East) – iad1
Cloning github.com/hritik2002/GitaGpt-Bot (Branch: main, Commit: 17356f1)
Previous build cache not available
Cloning completed: 401.653ms
Running "vercel build"
Vercel CLI 28.15.3
Running "install" command: `npm install`...
npm WARN deprecated puppeteer@13.7.0: < 18.1.0 is no longer supported
added 121 packages, and audited 122 packages in 6s
10 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
/vercel/path0/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:241
reject(new Error([
^
Error: Failed to launch the browser process!
[0212/144729.058867:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at onClose (/vercel/path0/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:241:20)
at Interface.<anonymous> (/vercel/path0/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:231:68)
at Interface.emit (node:events:525:35)
at Interface.close (node:internal/readline/interface:536:10)
at Socket.onend (node:internal/readline/interface:262:10)
at Socket.emit (node:events:525:35)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Node.js v18.12.1
Error: Command "node app.js" exited with 1
我的package.json
文件:
{
"dependencies": {
"axios": "^0.26.1",
"qrcode-terminal": "^0.12.0",
"whatsapp-web.js": "^1.18.0"
}
}
我的app.js
代码:
const qrcode = require("qrcode-terminal");
const { Client, LocalAuth, MessageMedia } = require("whatsapp-web.js");
const axios = require("axios");
async function QueryMessage(message) {
// performs certain task:
}
const client = new Client({
authStrategy: new LocalAuth(),
});
client.initialize();
client.on("qr", (qr) => {
qrcode.generate(qr, { small: true });
});
client.on("authenticated", () => {
console.log("AUTHENTICATED");
});
client.on("ready", () => {
console.log("Client is ready!");
});
const sendMessage = async (chat, message) => {
await chat.sendMessage(await QueryMessage(message));
};
//Replying Messages with image from url
client.on("message", async (message) => {
const chat = await message.getChat();
if (!chat.isGroup) {
sendMessage(chat, message.body);
}
});
2条答案
按热度按时间xsuvu9jc1#
你不能在Vercel中使用Puppeteer,Puppeteer是一个在后台运行的浏览器。
cnh2zyt32#
我在node.js中也有同样的问题,通过在创建客户端时添加--no-sandbox参数来解决。