我正在尝试将猫鼬包与 Cloudflare 工作人员一起使用。webpack 之后当我使用无服务器部署进行部署时,我收到此错误消息。
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: deploying route: example.com/api
Serverless: ❌ Fatal Error, Script Not Deployed!
Serverless: --> Error Code:10021
--> Error Message: "Uncaught TypeError: n(...).connect is not a function
at line 950
at line 1 in n
at line 1
at line 1
"
Serverless: ✅ Routes Deployed
在线 950
n(83).connect("mongodb://localhost/db",........
我的主要代码是
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request));
});
const mongoose = require("mongoose");
mongoose.connect("mongodb://localhost/db", {
useNewUrlParser: true
});
async function handleRequest(r) {
return new Response(r);
}
我也试过 mongodb 包。显示同样的问题。