Deno 学习笔记(1)安装及简单的request

Deno下载和安装

PowerShell

iwr https://deno.land/x/install/install.ps1 -useb | iex

Shell

curl -fsSL https://deno.land/x/install/install.sh | sh

Deno 升级

deno upgrade

升级到指定版本

deno upgrade --version 1.0.1

Hello World

官网给的Demo用来测试Deno是否安装成功

deno run https://deno.land/std/examples/welcome.ts

运行结果

编写一个简单的Http request

const url = Deno.args[0];
const res = await fetch(url);
const body = new Uint8Array(await res.arrayBuffer());
await Deno.stdout.write(body);

然后在shell中运行:

deno run --alow-net=example.com .\demo.ts http://example.com

运行结果

这里有个问题第一个就是我的VSCode语法提示会报错,但是程序是能正常运行的
语法报错

posted @ 2020-05-27 10:24  swan1024  阅读(466)  评论(0)    收藏  举报