deno

Deno permissions issue - Uncaught PermissionDenied: network access

拥有回忆 提交于 2020-06-29 04:26:21
问题 I'm trying out Deno and while running an example, I ran into error: $ deno run https://deno.land/std/examples/curl.ts https://example.com Download https://deno.land/std/examples/curl.ts Warning Implicitly using master branch https://deno.land/std/examples/curl.ts Compile https://deno.land/std/examples/curl.ts error: Uncaught PermissionDenied: network access to "https://example.com/", run again with the --allow-net flag at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11) at Object.sendAsync

Deno Uncaught AddrInUse: Only one usage of each socket address (protocol/network address/port) is normally permitted. (os error 10048)

拜拜、爱过 提交于 2020-06-29 04:13:11
问题 When I try to run my deno file I got os error 10048 , How can I solve this error? Thank you import { Application } from 'https://deno.land/x/oak/mod.ts' const app = new Application(); const port = 3000; app.use((ctx) => { ctx.response.body = "Hello World" }) app.listen({ port }) console.log(`localhost:${port}`) I tried to Run my Deno file but I got this error D:\Deno Documentation\deno3>deno run --allow-net ./server.js localhost:3000 error: Uncaught AddrInUse: Only one usage of each socket

Read and write whole directories with tar archive (Standard Library)

我与影子孤独终老i 提交于 2020-06-29 04:07:20
问题 This is a continuation of linked question. It seems to me, that current implementation of the std/archive/tar.ts module only allows reads and writes per file and not for whole directories. So far, my reference source are the test files, which only show case single file processing. But what if, for example, a directory ./my-dir/ with multiple files and a tar archive ./test.tar is given. How can I then utilize append, extract & Co. to efficiently write ./my-dir/ to ./test.tar archive and read

Deno: Processing tar archive results in checksum error (Standard Library)

寵の児 提交于 2020-06-28 05:01:34
问题 I would like to process a tar archive with help of tar.ts from Standard Library. The archive can be written successfully to test.tar by following code: import { Tar, Untar } from "https://deno.land/std/archive/tar.ts"; // create tar archive const tar = new Tar(); const content = new TextEncoder().encode("hello tar world!"); await tar.append("output.txt", { reader: new Deno.Buffer(content), contentSize: content.byteLength, }); await Deno.writeFile("./test.tar", tar.out); However, reading the

How to spawn child process and communicate with it Deno?

拥有回忆 提交于 2020-06-28 02:58:34
问题 Suppose I have 2 script, father.ts and child.ts, how do I spawn child.ts from father.ts and periodically send message from father.ts to child.ts ? 回答1: You have to use the Worker API father.ts const worker = new Worker("./child.ts", { type: "module", deno: true }); worker.postMessage({ filename: "./log.txt" }); child.ts self.onmessage = async (e) => { const { filename } = e.data; const text = await Deno.readTextFile(filename); console.log(text); self.close(); }; You can send messages using

How to pass command line arguments to Deno?

让人想犯罪 __ 提交于 2020-06-27 18:26:46
问题 I have a Deno app, that I wish to pass some command line args to. I searched the manual, but found nothing. I tried to use the same commands used in Node.js, assuming they might be sharing some for the std libraries, but it didn't work as well. var args = process.argv.slice(2); // Uncaught ReferenceError: process is not defined Any suggestions? 回答1: You can use Deno.args to access the command line arguments in Deno. To try it create a file test.ts : console.log(Deno.args); And run it with

Uncaught InvalidData: data did not match any variant of untagged enum ArgsEnum

人走茶凉 提交于 2020-06-27 10:53:05
问题 I'm enthusiastic about Deno so I'm giving it a try. Found a tutorial on building a REST API here. So, when I'm trying to run it, I get this InvalidData error: error: Uncaught InvalidData: data did not match any variant of untagged enum ArgsEnum at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11) at Object.sendAsync ($deno$/ops/dispatch_json.ts:98:10) at async Object.connect ($deno$/net.ts:216:11) at async Connection.startup (https://deno.land/x/postgres/connection.ts:138:17) at async Client

How to debug Deno in VSCode

断了今生、忘了曾经 提交于 2020-06-25 18:02:37
问题 How do we configure .vscode/launch.json to debug Deno projects? The IntelliSense the VSCode provides when I was in configurations didn't offer an option for Deno. Or is there an extension for this? 回答1: You need to attach the debugger, as per the deno manual. Create .vscode/launch.json replacing <entry_point> with your actual script and then F5 . { "version": "0.2.0", "configurations": [ { "name": "Deno", "type": "node", "request": "launch", "cwd": "${workspaceFolder}", "runtimeExecutable":

Where can I see deno downloaded packages?

社会主义新天地 提交于 2020-06-23 06:33:48
问题 I am new to deno and currently exploring for a minimum viable project in deno. I want to like npm which downloads the npm packages inside the folder node_modules , similarly I want to see the deno packages in a directory. In my current project I do not see any downloaded packages. Please suggest me where to look for deno packages. If I write dep.ts file to mention all the deno packages, can I use the same deno packages for some other projects. My question is bit similar to what Maven or

Where can I see deno downloaded packages?

我怕爱的太早我们不能终老 提交于 2020-06-23 06:33:17
问题 I am new to deno and currently exploring for a minimum viable project in deno. I want to like npm which downloads the npm packages inside the folder node_modules , similarly I want to see the deno packages in a directory. In my current project I do not see any downloaded packages. Please suggest me where to look for deno packages. If I write dep.ts file to mention all the deno packages, can I use the same deno packages for some other projects. My question is bit similar to what Maven or