{"id":560,"date":"2021-03-28T22:08:59","date_gmt":"2021-03-28T13:08:59","guid":{"rendered":"http:\/\/localhost:8000\/?p=560"},"modified":"2021-03-28T22:38:02","modified_gmt":"2021-03-28T13:38:02","slug":"deno","status":"publish","type":"post","link":"http:\/\/localhost:8000\/2021\/03\/deno.html","title":{"rendered":"\u521d\u3081\u3066\u306eDeno"},"content":{"rendered":"
Deno\u306f\u3001V8\u30a8\u30f3\u30b8\u30f3\u304a\u3088\u3073Rust\u3067\u7d44\u307e\u308c\u305f JavaScript \u3068 TypeScript\u306e\u30e9\u30f3\u30bf\u30a4\u30e0\u3067\u3001Node.js \u3092\u4f5c\u6210\u3057\u305f\u30e9\u30a4\u30a2\u30f3\u30fb\u30c0\u30fc\u30eb\u6c0f\u304c\u3001Node.js \u3067\u306e\u5f8c\u6094\u3092\u6539\u5584\u3059\u308b\u5f62\u3067\u4f5c\u6210\u3055\u308c\u305f\u3082\u306e\u3089\u3057\u3044\u3067\u3059\u3002\uff08\u8a73\u3057\u304f\u306f\u3001\u3053\u3061\u3089<\/a>\uff09<\/p>\n \u7279\u5fb4\u3068\u3057\u3066\u306f\u4ee5\u4e0b\u304c\u6319\u3052\u3089\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n \u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3057\u3066\u304a\u304b\u306a\u3044\u3068\u3001VS Code\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u304c\u3046\u307e\u304f\u52d5\u3044\u3066\u304f\u308c\u307e\u305b\u3093\u3002 \u307e\u305a\u306f \u5b9f\u884c\u3059\u308b\u3068\u3046\u307e\u304f\u30d7\u30ea\u30f3\u30c8\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n \u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n http:\/\/localhost:8080\/<\/a> \u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3061\u3083\u3093\u3068 <\/p>\n \u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u5f15\u6570\u3067\u6307\u5b9a\u3057\u305f\u30ef\u30fc\u30c9\u3067Google\u691c\u7d22\u3057\u3001\u7d50\u679c\u3092\u30ed\u30b0\u306b\u51fa\u529b\u3059\u308b\u3060\u3051\u306e\u7c21\u5358\u306a\u30b9\u30af\u30ea\u30d7\u30c8\uff08google_search.ts\uff09\u3092\u66f8\u3044\u3066\u307f\u307e\u3057\u305f\u3002 \u3053\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u3001\u5358\u7d14\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9f\u884c\u3059\u308b\u3068\u3001 \u4ee5\u4e0b\u306e\u3088\u3046\u306b \u4e0a\u8a18\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3001\u5b9f\u306fVS Code\u4e0a\u3067\u307f\u308b\u3068\u3044\u304f\u3064\u304b\u30ef\u30fc\u30cb\u30f3\u30b0\u304c\u51fa\u3066\u307e\u3059\u3002 \u3053\u308c\u306f\u3001linter\u304c\u666e\u901a\u306etypescript\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u30c1\u30a7\u30c3\u30af\u3057\u3066\u3044\u308b\u305f\u3081\u3067\u3001Deno\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3068\u3057\u3066\u8a8d\u8b58\u3055\u305b\u308c\u3070\u30ef\u30fc\u30cb\u30f3\u30b0\u306f\u6d88\u3048\u307e\u3059\u3002<\/p>\n \u307e\u305a\u3001\u4ee5\u4e0b\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3001 \u4ee5\u4e0b\u306e\u3088\u3046\u306a .vscode\/settings.json \u3092\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u76f4\u4e0b\u306b\u4f5c\u6210\u3057\u3066\u3042\u3052\u308c\u3070\u30ef\u30fc\u30cb\u30f3\u30b0\u306f\u6d88\u3048\u307e\u3059\u3002<\/p>\n \u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u6709\u52b9\u306b\u3059\u308b\u3068\u3001\u30ef\u30fc\u30cb\u30f3\u30b0\u304c\u6d88\u3048\u308b\u3060\u3051\u3067\u306a\u304f\u3001 Deno \u306b\u306f\u3001deno lint \u3068\u3044\u3046 linter \u304c\u6a19\u6e96\u3067\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n \u73fe\u72b6\u3001\u30eb\u30fc\u30eb\u306e\u8a2d\u5b9a\u3084\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u306f\u3067\u304d\u306a\u3044<\/strong>\u307f\u305f\u3044\u3067\u3059\u3002 \u4e0a\u8a18VSCode\u62e1\u5f35\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u4e0a\u3067\u3001.vscode\/settings.json \u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u3066\u3042\u3052\u308b\u3068\u3001VSCode\u4e0a\u3067\u6709\u52b9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n \u8a66\u3057\u306b\u3001 \u3053\u306e\u30ef\u30fc\u30cb\u30f3\u30b0\u3092\u7121\u8996\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b \u307e\u305f\u3001\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3067\u5b9f\u884c\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n Deno \u3067\u306f\u3001deno fmt \u3068\u3044\u3046\u30d5\u30a9\u30fc\u30de\u30c3\u30bf\u30fc\u304c\u6a19\u6e96\u3067\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n .vscode\/settings.json \u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u3066\u3042\u3052\u308b\u3068\u3001VSCode\u4e0a\u3067\u6709\u52b9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n \u307e\u305f\u3001\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u3067\u5b9f\u884c\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n \u30b9\u30af\u30ea\u30d7\u30c8\u3092\u66f8\u304f\u5206\u306b\u306f\u3001Deno\u306f\u3068\u3066\u3082\u30cf\u30fc\u30c9\u30eb\u304c\u4f4e\u3044\u3068\u611f\u3058\u307e\u3057\u305f\u3002\u304a\u305d\u3089\u304f\u3001\u7c21\u7d20\u306aWeb\u30b5\u30fc\u30d0\u3092\u7acb\u3066\u305f\u308a\u3059\u308b\u306e\u3082\u5927\u4e08\u592b\u3067\u3057\u3087\u3046\u3002<\/p>\n \u4e00\u65b9\u3067\u3001\u307b\u3068\u3093\u3069\u306enpm\u30d1\u30c3\u30b1\u30fc\u30b8\u306fDeno\u3067\u306f\u52d5\u304b\u306a\u3044\u305f\u3081\u3001\u30cb\u30c3\u30c1\u306a\u8981\u4ef6\u3078\u306e\u5bfe\u5fdc\u304c\u5fc5\u8981\u306a\u5834\u5408\u306b\u3001\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u63d0\u4f9b\u3055\u308c\u3066\u304a\u3089\u305a\u8a70\u3093\u3067\u3057\u307e\u3046\u61f8\u5ff5\u304c\u3042\u308a\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001Excel \u51fa\u529b\u3059\u308b\u3088\u3046\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u306fDeno\u306b\u306f\u306a\u3055\u305d\u3046\u3067\u3057\u305f\u3002<\/p>\n \u305d\u3046\u3044\u3046\u610f\u5473\u3067\u3001\u304a\u8a66\u3057\u306a\u3089\u3044\u3044\u3082\u306e\u306e\u3001\u30d7\u30ed\u30c0\u30af\u30b7\u30e7\u30f3\u3067\u4f7f\u3046\u306b\u306f\u4e0d\u5b89\u611f\u304c\u3042\u308a\u3001\u300c\u73fe\u6642\u70b9\u3067\u306f\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u5229\u7528\u3059\u308b\u3050\u3089\u3044\u306b\u3068\u3069\u3081\u3066\u304a\u3044\u305f\u65b9\u304c\u7121\u96e3\u304b\u306a\u300d\u3068\u3044\u3046\u611f\u60f3\u3067\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":" \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8 \u516c\u5f0f\u30de\u30cb\u30e5\u30a2\u30eb \u30bd\u30fc\u30b9\u30b3\u30fc\u30c9 \u7279\u5fb4 Deno\u306f\u3001V8\u30a8\u30f3\u30b8\u30f3\u304a\u3088\u3073Rust\u3067\u7d44\u307e\u308c\u305f JavaScript \u3068 TypeScript\u306e\u30e9\u30f3\u30bf\u30a4\u30e0\u3067\u3001Node.js \u3092\u4f5c\u6210\u3057\u305f\u30e9\u30a4\u30a2\u30f3\u30fb\u30c0\u30fc\u30eb\u6c0f\u304c\u3001Node.js \u3067\u306e\u5f8c\u6094\u3092\u6539\u5584\u3059\u308b\u5f62\u3067\u4f5c\u6210\u3055\u308c\u305f\u3082\u306e\u3089\u3057\u3044\u3067\u3059\u3002\uff08\u8a73\u3057\u304f\u306f\u3001\u3053\u3061\u3089\uff09 \u7279\u5fb4\u3068\u3057\u3066\u306f\u4ee5\u4e0b\u304c\u6319\u3052\u3089\u308c\u3066\u3044\u307e\u3059\u3002 \u30bb\u30ad\u30e5\u30a2\u3067\u3042\u308b \u660e\u793a\u7684\u306b\u3057\u306a\u3044\u9650\u308a\u3001\u30d5\u30a1\u30a4\u30eb\u30fb\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30fb\u74b0\u5883\u3078\u30a2\u30af\u30bb\u30b9\u3067\u304d\u306a\u3044 \u4f55\u3082\u3057\u306a\u304f\u3066\u3082 TypeScript\u3092\u30b5\u30dd\u30fc\u30c8\u3059\u308b \u5358\u4e00\u306e\u5b9f\u884c\u30d5\u30a1\u30a4\u30eb\u3092\u30ea\u30ea\u30fc\u30b9\u3059\u308b \u4f9d\u5b58\u95a2\u4fc2\u30a4\u30f3\u30b9\u30da\u30af\u30bf\uff08deno info\uff09\u3084\u30b3\u30fc\u30c9\u30d5\u30a9\u30fc\u30de\u30c3\u30bf\u30fc\uff08deno fmt\uff09\u304c\u7d44\u307f\u8fbc\u307f\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u3068\u3057\u3066\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b \u30ec\u30d3\u30e5\u30fc\u30fb\u52d5\u4f5c\u78ba\u8a8d\u6e08\u307f\u306e\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u304c Deno Land \u3067\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308b \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb brew install deno deno upgrade –ver <\/span>Continue Reading<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[25],"tags":[],"_links":{"self":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/560"}],"collection":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/comments?post=560"}],"version-history":[{"count":1,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/560\/revisions"}],"predecessor-version":[{"id":569,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/560\/revisions\/569"}],"wp:attachment":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/media?parent=560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/categories?post=560"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/tags?post=560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}\n
\n
\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n
brew install deno\ndeno upgrade --version 1.8.1\ndeno info\n> DENO_DIR location: "\/Users\/xxx\/Library\/Caches\/deno"\n> Remote modules cache: "\/Users\/xxx\/Library\/Caches\/deno\/deps"\n> TypeScript compiler cache: "\/Users\/xxx\/Library\/Caches\/deno\/gen"<\/code><\/pre>\n
\n\u5229\u7528\u53ef\u80fd\u306a\u30d0\u30fc\u30b8\u30e7\u30f3\u306f\u3001\u3053\u3061\u3089<\/a>\u3067\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\u52d5\u304b\u3057\u3066\u307f\u308b<\/h2>\n
hello deno!<\/code>\u3092\u30d7\u30ea\u30f3\u30c8<\/h3>\n
hello deno!<\/code>\u3068\u3044\u3046\u6587\u5b57\u3092\u30d7\u30ea\u30f3\u30c8\u3059\u308b\u3060\u3051\u306e\u3001hello.ts \u3092\u5b9f\u88c5\u3057\u307e\u3059\u3002<\/p>\n
console.log('hello deno!');<\/code><\/pre>\n
deno run hello.ts\n> Check file:\/\/\/Users\/xxx\/workplace\/deno_samples\/src\/hello.ts\n> hello deno!<\/code><\/pre>\n
hello deno!<\/code>\u3092\u8fd4\u3059Web\u30b5\u30fc\u30d0<\/h3>\n
hello deno!<\/code>\u3068\u8868\u793a\u3055\u308c\u305f\u30da\u30fc\u30b8\u3092\u8fd4\u3059\u3060\u3051\u306eWeb\u30b5\u30fc\u30d0\u3092\u7acb\u3066\u308b\u3001webserver.ts \u3092\u5b9f\u88c5\u3057\u307e\u3059\u3002<\/p>\n
import { serve } from "https:\/\/deno.land\/std@0.91.0\/http\/server.ts";\n\nconst server = serve({ hostname: "0.0.0.0", port: 8080 });\nconsole.log("WEB server running on http:\/\/localhost:8080\/");\nfor await (const request of server) {\n request.respond({ status: 200, body: "Hello Deno!" });\n}\n<\/code><\/pre>\n
deno run --allow-net webserver.ts\n> Check file:\/\/\/Users\/xxx\/workplace\/deno_samples\/src\/webserver.ts\n> web server running on http:\/\/localhost:8080\/<\/code><\/pre>\n
hello deno!<\/code>\u3068\u8868\u793a\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n
Google\u691c\u7d22\u30b9\u30af\u30ea\u30d7\u30c8<\/h3>\n
\n\u6587\u5b57\u5217\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3001Document\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5909\u63db\u3059\u308b\u305f\u3081 deno-dom<\/a> \u3068\u3044\u3046 thrid party \u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3066\u307e\u3059\u3002<\/p>\nimport { DOMParser, HTMLDocument } from "https:\/\/deno.land\/x\/deno_dom\/deno-dom-wasm.ts";\n\nconst search = async(query: string) => {\n console.log(`========= query: ${query} =========`)\n const response: Response = await fetch(`https:\/\/www.google.com\/search?q=${query}`);\n const parser: DOMParser = new DOMParser();\n const document: HTMLDocument | null = parser.parseFromString(await response.text(), 'text\/html');\n if (document !== null) {\n Array.from(document.querySelectorAll('body h3')).slice(0, 5).forEach((e) => console.log(e.textContent));\n }\n}\n\nawait search(Deno.args[0]);<\/code><\/pre>\n
PermissionDenied<\/code>\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3059\u3002
\n\u7279\u5fb4\u306b\u3082\u3042\u308a\u307e\u3057\u305f\u304c\u3001Deno\u3067\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a2\u30af\u30bb\u30b9\u304c\u8a31\u53ef\u3055\u308c\u3066\u306a\u3044\u305f\u3081\u3067\u3059\u3002<\/p>\ndeno run google_search.ts AAA\n> Check file:\/\/\/Users\/xxx\/workplace\/deno_samples\/src\/google_search.ts\n> error: Uncaught PermissionDenied: network access to "www.google.com", run again with the --allow-net flag\n const response = await fetch(`https:\/\/www.google.com\/search?q=${query}`);<\/code><\/pre>\n
--allow-net<\/code>\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001\u7121\u4e8b\u5b9f\u884c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n
deno run --allow-net="www.google.com" google_search.ts AAA\n> ========= query: AAA =========\n> AAA\uff08\u30c8\u30ea\u30d7\u30eb\u30fb\u30a8\u30fc\uff09OFFICIAL WEBSITE\n> AAA\n> AAA Party\n> PROFILE | AAA\uff08\u30c8\u30ea\u30d7\u30eb\u30fb\u30a8\u30fc\uff09OFFICIAL WEBSITE\n> AAA \/ \u300cLIFE\u300dMusic Video - YouTube<\/code><\/pre>\n
VSCode\u306e\u8a2d\u5b9a<\/h2>\n
Deno \u62e1\u5f35<\/h3>\n
\n<\/p>\n\n
\n<\/p>\n{\n "deno.enable": true\n}<\/code><\/pre>\n
Command + \u30af\u30ea\u30c3\u30af<\/code>\u3067 third party \u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306b\u98db\u3079\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n
deno lint<\/h3>\n
\n
\n\u4e0a\u8a18\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u5217\u6319\u3055\u308c\u3066\u3044\u308b\u30eb\u30fc\u30eb\u304c\u5168\u3066\u9069\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n{\n "deno.enable": true,\n "deno.lint": true, \/\/ \u3053\u306e\u8a2d\u5b9a\u3092\u8ffd\u52a0\n}<\/code><\/pre>\n
debugger;<\/code>\u3092\u8ffd\u52a0\u3057\u3066\u307f\u305f\u3068\u3053\u308d\u3001\u3061\u3083\u3093\u3068\u30ef\u30fc\u30cb\u30f3\u30b0\u304c\u8868\u793a\u3055\u308c\u307e\u3057\u305f\u3002
\n<\/p>\ndeno-lint-ignore<\/code>\u3067\u5bfe\u8c61\u306e\u30eb\u30fc\u30eb\u3092\u7121\u8996\u3059\u308b\u3088\u3046\u306b\u30b3\u30e1\u30f3\u30c8\u3057\u3066\u3042\u3052\u308c\u3070\u826f\u3044\u3067\u3059\u3002<\/p>\n
\/\/ deno-lint-ignore no-debugger\n debugger;<\/code><\/pre>\n
deno lint --unstable google_search.ts \n> (no-debugger) `debugger` statement is not allowed\n> debugger;\n> ^^^^^^^^^\n> at \/Users\/xxx\/workplace\/deno_samples\/src\/google_search.ts:4:4\n> hint: Remove the `debugger` statement\n> Found 1 problem\n> Checked 1 file<\/code><\/pre>\n
deno fmt<\/h3>\n
\n
{\n "deno.enable": true,\n "[typescript]": { \/\/ \u3053\u306e\u8a2d\u5b9a\u3092\u8ffd\u52a0\n "editor.defaultFormatter": "denoland.vscode-deno",\n "editor.formatOnSave": true,\n },\n}<\/code><\/pre>\n
deno fmt\n> \/Users\/xxx\/workplace\/deno_samples\/src\/google_search.ts\n> Checked 2 files<\/code><\/pre>\n
\u6240\u611f<\/h2>\n