LoginSignup
1
0

More than 3 years have passed since last update.

Node.jsに変わるかも?と言われている、Deno 1.0がリリースされたので素振りしてみた。

Last updated at Posted at 2020-05-14

Deno1.0がリリースされたことで、twitterで界隈で話題になっていたので、素振りしてみた。(メモ程度です)

詳細は公式サイトをご確認ください。
https://deno.land/

まずは、インストール

brew install deno

これで準備はOK!まずは、「Getting Started」をやってみた。

実行コマンド: deno run (ファイル名)

deno run https://deno.land/std/examples/welcome.ts
// => Welcome to Deno 🦕

http://localhost:8000/にアクセスすると、「Hello World」が表示される。

hello_http.ts
import { serve } from "https://deno.land/std@0.50.0/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 --allow-net hello_http.ts

「--allow-net」の位置が曲者で最後につけてエラーになり、位置に注意です!
ここtwiiter見てても一度ハマる人が多いようなので。
「--allow-net」はセキュリティの関係で必要みたいです。

今後もウォッチしていこう!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0