Deno 是一个 JavaScript/TypeScript 的运行时,默认使用安全环境执行代码,有着卓越的开发体验。
使用 PowerShell (Windows)
powershelliwr https://deno.land/x/install/install.ps1 -useb | iex
Shell (Mac, Linux)
bashcurl -fsSL https://deno.land/x/install/install.sh | sh
Chocolatey (Windows)
powershellchoco install deno
Scoop (Windows)
powershellscoop install deno
welcome.ts
javascriptconsole.log('Welcome to Deno!');
运行结果
powershelldeno run https://deno.land/std/examples/welcome.ts
代码
javascriptimport Aqua from 'https://deno.land/x/aqua/aqua.ts';
const app = new Aqua(8000);
app.get('/', (req) => {
return 'Deno server running on port 8000';
});
添加权限
powershelldeno run --allow-net server.ts
import map file
json{
"imports": {
"aqua/": "https://deno.land/x/aqua/"
}
}
代码
javascriptimport Aqua from 'aqua/aqua.ts';
const app = new Aqua(8000);
app.get('/', () => {
return 'Deno server running on port 8000';
});
执行命令
powershelldeno run --allow-net --import-map=import_map.json server-with-map.ts
本文作者:谭三皮
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!