Deno

D

Deno

Chat about Deno, a modern runtime for JavaScript and TypeScript.

Join

How to use Buffers again? Old node path no longer exists

Previously, I used export * from "https://deno.land/std@0.177.0/node/internal/buffer.mjs";. I updated a project to use the latest std library and I have no idea how to get buffers back.

How use namespace on Deno

i am trying to use the same namespace in multiple modules but what used to work in node, doesn't work in deno: ```ts /* test1.ts */ /// <reference path="./test2.ts" />...

Restart Deno process on crash

Hello, The following Node snippet allows a script to restart on crash : ```js import { spawn...

best practice when spawning commands that require sudo?

I am building a command line utility in deno that leverages data coming from tcpdump. To get any meaningful data out of tcpdump, I need elevated permissions. To keep this command portable, that means running sudo tcpdump inside my deno program. How can I set up deno permissions to run a specific command executed through sudo? A simple permission of --allow-run=sudo would be dangerous. I could just let the user approve each time, but even then, all they know is that they are approving sudo, there is no other knowledge of what the subcommand is: `` ┌ ⚠️ Deno requests run access to "sudo". ├ Requested by Deno.Command().spawn()` API. ├ Run again with --allow-run to bypass this prompt....

Should "exists" function from STD be used as a last resort?

There was an undo deprecation for "exists" functions but still in the code it says this: Note: Do not use this function if performing a check before another operation on that file. Doing so creates a race condition. Instead, perform the actual file operation directly. So basically this message and the description in the PR, would mean use it but as last resort? e.g: third party scenarios?...

Chaining Tasks and using --watch

Is there a way to chain Deno tasks or something to that accord? I'd like to run esbuild from the command line to bundle/transpile some client JS and then have Deno start my dev webserver in watch mode. So each time a file is touched it runs esbuild and then Deno again.

How to setup deno for Lunarvim?

I've followed the steps to install the LSP for deno, but the completion and formatter doesn't work https://lunarvim.org/docs/languages/typescript...

Unexpected token 'export' (deno_core)

Playing around with ModuleLoaders, but doesn't seem to make a difference Scripts containing the export keyword don't load due to above error How can I allow the keyword?...

global is not defined

Why Deno doesn't have global like node.js? There is globalThis, but some things from npm packages are based exactly on global, which can cause problems (as it happened to me) This happened to me when I tried to use the Array type from mongoose (import { Types } from "mongoose"). This is an extended version of array, which inherits an array from global.Array, which works in deno as an inheritance from undefined...

Using querySelector on Node

I am doing something like: ```ts const nodeList: NodeList = document.querySelectorAll(".foo"); const nodes = [...nodeList]; const result = nodes.map((n: Node) => n.querySelector("span"));...

Are there any plans to support an equivalent to emitDecoratorMetadata?

That's it really... I appreciate that Deno doesn't emit anything, so the option would be different, but access to metadata in decorators is incredibly useful for things like DI and other cross-cutting concerns....

Simpler way to read a file relative to current module?

So I wrote a little helper function for reading the text content of a file relative to the current module. I came up with the following, but is there any simpler way that I'm missing? It seems a bit wordy 😄 ```ts import * as path from "std//path/mod.ts"; ...

error: BadResource: Bad resource ID

I'm writing tests for https://github.com/deno-libs/tinyhttp/pull/9. ```js import { describe, expect, it, run } from 'https://deno.land/x/tincan@1.0.1/mod.ts' import { App } from '../../app.ts'...

Recent deployment not working?

Hi there I have an api that was working just fine not sure what happen but new deployments are not working, on my local works, and the deployment from 5 days ago works, but any new deployment don't I'm using the pusher library with esm.sh, just wonder if anything changed recently 👀 I mean the deployment works** but the code endpoint dont not sure why we didnt change the code...

How do you get the path to a file relative to the module which is referencing it?

const GET_PROGRAM_QUERY = Deno.readFileSync("./GetProgram.gql");
const GET_PROGRAM_QUERY = Deno.readFileSync("./GetProgram.gql");
GetProgram.gql is a file in the same directory as the calling module. The above doesn't work. Any ideas?...

Investigating memory leak after adding new app dependency

Hi, I added an OpenTelemetry metrics reporting loop to a Deno program and found that Deno began leaking memory (300MB+, until it hits OOM and gets killed). This program was previously stable at 40MB RAM usage. To begin, I graphed Deno.memoryUsage() and it seems like the leaked memory is all external. How else can I investigate the issue? Anything else I can add to my typescript to observe this?...

VScode deno lint blew up again after update.

It seems every time there's an extension update VScode lint blows up and will stop recognizing top level awaits, and all kinds of other things. How can I fix the latest one?

Help debugging command that doesn't exit.

Is there a way to have Deno tell me what async tasks are still pending when a program ends? I'm using a third-party API, and AFAICT awaiting all the promises I can, but I still get to the end of my main() and deno doesn't exit. So I've got: ...

import cache not working

I can't install cache of my http imports:

Why isn't this error caught?

Basic code example: ``` try { Deno.remove("fakefile"); } catch (err) {...