#I cant install deno by running this command: curl -fsSL https://deno.land/install.sh | sh

1 messages · Page 1 of 1 (latest)

pliant valve
trim fern
#

What's the problem?

vague hemlock
#

Deno installed properly, you probably didn’t add the 2 export lines to your .bashrc or similar and thus think that deno didn’t install since the command doesn’t work

pliant valve
#

I can't work with deno

#

I will paste my code here, down below

#

import { serve } from "https://deno.land/std/http/server.ts";

// setup server
const server = serve({ port: 3000 });
console.log('http://localhost:3000/');

for await (const req of server) {

// serve index page
if (req.url === '/') {
    req.respond({
        status: 200,
        body: await Deno.open('./public/index.html')
    })
}

}

shut flower
#

So what’s the error you get?

whole tiger
#

Your problem is not deno itself. It's your code. The error explains it pretty well:

Listening on http://localhost:8000/
http://localhost:3000/
error: Uncaught (in promise) TypeError: server is not async iterable
for await (const req of server) {
                        ^
    at file:///E:/img-view/saba.ts:7:25

Generally, I would use Deno.serve instead of the function you use, because it's deprecated (see screenshot below). Then, your code would look like this:

Deno.serve({port: 3000}, (req: Request) => {
    if (req.url === "/") return new Response(Deno.readTextFileSync("./public/index.html"), {status: 200});
    else return new Response("Not Found", {status: 404});
});
potent plover
#

curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number