ไม่มี package manager
และ centralize registry
แบบ ของ Node จะเรียกใช้ Library ต่างๆ จาก Internet
# node
const express = require("express")
# deno
import { Application } from "https://deno.land/x/oak/mod.ts";
จะใช้งานผ่าน URL ตรงๆ
import { serve } from "https://deno.land/[email protected]/http/server.ts";
const s = serve({ port: 8000 });
console.log("http://localhost:8000/");
for await (const req of s) {
req.respond({ body: "Hello World\n" });
}
file system
network
environment variable
ได้เลย ต้องทำการขออนุญาติก่อนถึงจะใช้งานได้ตัวอย่าง run code simple
# main.js
import { serve } from "https://deno.land/[email protected]/http/server.ts";
const s = serve({ port: 8000 });
console.log("http://localhost:8000/");
for await (const req of s) {
req.respond({ body: "Hello World\n" });
}
$ deno run main.js
...
Download https://deno.land/[email protected]/http/server.ts
Download https://deno.land/[email protected]/encoding/utf8.ts
Download https://deno.land/[email protected]/io/bufio.ts
Download https://deno.land/[email protected]/_util/assert.ts
Download https://deno.land/[email protected]/async/mod.ts
Download https://deno.land/[email protected]/http/_io.ts
Download https://deno.land/[email protected]/async/deferred.ts
Download https://deno.land/[email protected]/async/delay.ts
Download https://deno.land/[email protected]/async/mux_async_iterator.ts
Download https://deno.land/[email protected]/textproto/mod.ts
Download https://deno.land/[email protected]/http/http_status.ts
Download https://deno.land/[email protected]/bytes/mod.ts
Compile https://deno.land/[email protected]/http/server.ts
error: Uncaught PermissionDenied: network access to "0.0.0.0:8000", run again with the --allow-net flag
at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
at Object.sendSync ($deno$/ops/dispatch_json.ts:72:10)
at Object.listen ($deno$/ops/net.ts:51:10)
at Object.listen ($deno$/net.ts:152:22)
at serve (https://deno.land/[email protected]/http/server.ts:283:25)
at file:///Users/jaedsada/project/hobbies/playground/deno-simple/main.js:2:11
จะเจอ Error Permission denies ไม่สามารถ เข้าถึง Network ได้
deno run --allow-net main.js
...
http://localhost:8000/
$ curl localhost:8000
...
Hello World
Ref: