Deno oak error: Uncaught AssertionError: Unexpected skip of the emit

Deno oak error: Uncaught AssertionError: Unexpected skip of the emit

我在尝试 运行 简单 Deno Js OAK 中间件服务器时遇到错误:

Ubuntu 18.04, 
Deno 1.0.4, 
v8 8.4.300, 
typescript 3.9.2 

通过 运行宁 deno run index.js 或 运行宁 deno run -A index.js

$ deno run index.js
Compile file:///home/some/tst/index.js
error: Uncaught AssertionError: Unexpected skip of the emit.
    at Object.assert ($deno$/util.ts:33:11)
    at compile ($deno$/compiler.ts:1170:7)
    at tsCompilerOnMessage ($deno$/compiler.ts:1338:22)
    at workerMessageRecvCallback ($deno$/runtime_worker.ts:72:33)
    at file:///home/some/dcode/tst/__anonymous__:1:1

这是我的 index.js 文件代码:

import { Application } from "https://deno.land/x/oak/mod.ts";

const app = new Application();

app.use((ctx) => {
  ctx.response.body = "Hello World!";
});

await app.listen({ port: 8000 });

这是 v1.0.3v1.0.4 中引入的问题:https://github.com/denoland/deno/issues/6082 并且它仍在 1.0.5

中发生

在修复之前,解决方案是将 Deno 降级到 1.0.0 并使用 Oak 4.0.0,这是适合该 Deno 版本的 Oak 版本。

import { Application } from 'https://deno.land/x/oak@v4.0.0/mod.ts'

要降级 Deno,您可以执行 following:

curl -fsSL https://deno.land/x/install/install.sh | sh -s v1.0.0

或者如果您使用的是 Windows:

$v="1.0.0"; iwr https://deno.land/x/install/install.ps1 -useb | iex

将文件类型从 .js 更改为 .ts。

我在 Deno 的入门部分中使用 "complex program" 介绍我,但在我将文件类型从 javascript 更改为打字稿之前,我无法 运行 该程序.希望对你有所帮助!