gpt4 book ai didi

typescript - 使用 deno deploy 时 deno.stat 不是函数报错

转载 作者:行者123 更新时间:2023-12-05 05:55:03 25 4
gpt4 key购买 nike

我在使用 deno deploy 部署我的 deno 代码时遇到问题。该代码使用 deployctl 在本地完美运行,但在部署时失败。

import { Application } from "./deps.ts";
const app = new Application();

// Send static content
app.use(async (context) => {
await context.send({
root: `${Deno.cwd()}/public`,
index: "index.html",
});
});

addEventListener("fetch", app.fetchEventHandler());

这是一个简单的服务器,提供公共(public)目录中的静态文件。任何帮助表示赞赏。谢谢

最佳答案

这是 Deno Deploy 的运行时 API 引用链接:

https://deno.com/deploy/docs/runtime-api/

文档顶部的描述文本中包含以下内容:

Deno Deploy Runtime helps you write web servers in TypeScript/JavaScript using the Web APIs. It's different from Deno but aims to have similar APIs where applicable.

The following Web and Deno APIs are supported on Deno Deploy Runtime...

它继续提供 Deploy 中可用的 Deno 和 Web API 的详尽列表。

这是文件系统 API 引用的链接:

https://deno.com/deploy/docs/runtime-fs/

以下是撰写此答案时包含的内容:

Deno Deploy supports a limited set of file system APIs available in Deno. Your project should be linked to a GitHub repository in order to use these APIs. URL deployments do not support these APIs and will result in an exception when used.

  • Deno.cwd
  • Deno.readDir
  • Deno.readFile
  • Deno.readTextFile

如果您通读该列表,您会注意到 Deno.stat 未包含在内。它不在 Deno Deploy 的可用方法中。

关于typescript - 使用 deno deploy 时 deno.stat 不是函数报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69554887/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com