SabaMazmishvili
SabaMazmishvili3mo ago

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

No description
6 Replies
Leokuma
Leokuma3mo ago
What's the problem?
Bloxs
Bloxs3mo ago
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
SabaMazmishvili
SabaMazmishvili3mo ago
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') }) } }
krml
krml3mo ago
So what’s the error you get?
DNA
DNA3mo ago
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
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});
});
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});
});
DNA
DNA3mo ago
No description