1

I am getting error when trying to run simple Deno Js OAK middleware server on my:

Ubuntu 18.04, 
Deno 1.0.4, 
v8 8.4.300, 
typescript 3.9.2 

By running either deno run index.js or running 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

This is my index.js file code:

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 });
Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
Nezir
  • 6,727
  • 12
  • 54
  • 78

2 Answers2

3

Change the file type from .js to .ts.

I was introducing me in Deno with the "complex program" in its Getting started section and I was unable to run the program until I had change the file type from javascript to typescript. I hope have helped you!

johan_apo
  • 64
  • 2
1

This is an issue introduced in v1.0.3 or v1.0.4: https://github.com/denoland/deno/issues/6082 and it's still happening in 1.0.5

Until it's fixed, the solution is to downgrade Deno to 1.0.0 and use Oak 4.0.0, which is the appropriate Oak version for that Deno version.

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

To downgrade Deno, you can do the following:

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

or if you're using Windows:

$v="1.0.0"; iwr https://deno.land/x/install/install.ps1 -useb | iex
Marcos Casagrande
  • 37,983
  • 8
  • 84
  • 98
  • 1
    Your answer was solution. I had to downgrade and tested all versions from v1.0.1,v1.0.2, v1.0.3,v1.0.4, v1.0.5 latest it works on is v1.0.3 with oak@v4.0.0. Thank you! Note: I used deno version manager to install all these verison https://github.com/axetroy/dvm – Nezir Jun 04 '20 at 11:37