cmorten / opine

Minimalist web framework for Deno ported from ExpressJS.
https://github.com/cmorten/opine/blob/main/.github/API/api.md
MIT License
854 stars 43 forks source link

Error executing sample script from https://deno.land/x/opine #39

Closed rglowrey closed 4 years ago

rglowrey commented 4 years ago

Issue

Setup:

Error when executing deno sample script from https://deno.land/x/opine

Details

I saved the sample script with name "sampleOpine.ts", then executed it as below. It threw an error as follows:

deno run sampleOpine.ts Check file:///home/rick/Working/Playpen/deno/OpineTemplate/sampleOpine.ts error: TS2305 [ERROR]: Module '"./_utils"' has no exported member 'normalizeEncoding'. import { notImplemented, normalizeEncoding } from "./_utils.ts";


    at https://deno.land/std/node/buffer.ts:3:26

Not quite sure what to do with this, or if it's my configuration that's the problem.  NB: I was able to successfully run a Deno server app using OAK on the same machine.
asos-craigmorten commented 4 years ago

@rglowrey ah yes, saw this is in one of my other repos - one of the subdependencies hasn’t locked its versions causing this issue - I’ll get a patch out this morning shortly.

asos-craigmorten commented 4 years ago

@rglowrey please can you try out 0.17.0 and see if that is fixed for you? 🙂 I would also recommend always using a specific version of opine - the main branch is not 100% guaranteed to be stable (though is generally the plan!).

REF: https://github.com/asos-craigmorten/opine/releases/tag/0.17.0

rglowrey commented 4 years ago

No, didn't fix it.

Here's the code I ran:

import { opine } from "https://deno.land/x/opine@0.17.0/mod.ts";

const app = opine();

app.use((req, res) => {
  res.send("Hello World");
});

app.listen(3000);

Here's the result:

rick@rick-XPS-8920:~/Working/Playpen/deno/OpineTemplate$ deno run --allow-net sampleOpine.ts
Check file:///home/rick/Working/Playpen/deno/OpineTemplate/sampleOpine.ts
error: TS2305 [ERROR]: Module '"./_utils"' has no exported member 'normalizeEncoding'.
import { notImplemented, normalizeEncoding } from "./_utils.ts";
                         ~~~~~~~~~~~~~~~~~
    at https://deno.land/std/node/buffer.ts:3:26
asos-craigmorten commented 4 years ago

@rglowrey Hmm... the classic and somewhat unhelpful "works for me"!

Can you try with the --reload flag? I wonder if you've got a cached "bad" subdependency somewhere? I.e.

$ deno run --allow-net --allow-read --reload sampleOpine.ts
rglowrey commented 4 years ago

Now I get to give the classic "so it really WAS me all along!". Yes, running with the --reload flag did the trick. Also, when I ran it with the first line import { opine } from "https://deno.land/x/opine@main/mod.ts"; it worked fine after that --reload. Thanks for your help, and sorry for the bother.

asos-craigmorten commented 4 years ago

@rglowrey no bother at all! I believe the initial problem lay with Opine :joy: or specifically one of it's dependencies - something I think needs ironed out in Deno is sub-dependency resolution, conflicts etc. I don't think there is a way to "lock" versions for consumers of a module. The only thing consumers can do afaik is find a "good" version and then use the --lock-write and subsequently --lock flags to protect themselves from these errors - I don't think it can be fixed upstream just yet...?

Glad it works now anyway!