Questions tagged [deno]

A secure runtime for JavaScript and TypeScript.

Deno is a simple, modern, and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust.

  • Secure by default. No file, network, or environment access, unless explicitly enabled.
  • Supports TypeScript out of the box.
  • Ships only a single executable file.
  • Has built-in utilities like a dependency inspector (deno info) and a code formatter (deno fmt).
  • Has a set of reviewed (audited) standard modules that are guaranteed to work with Deno deno.land/std
919 questions
101
votes
4 answers

How to use npm module in DENO?

Deno is super cool. I saw it in the morning and want to migrate to deno now. I was trying to move my existing nodejs script to deno. Can any one help me on how to use npm modules in deno. I need esprima module. This one has the package…
Vinod Sai
  • 1,956
  • 3
  • 13
  • 23
61
votes
3 answers

deno vs ts-node : what's the difference

I'm working on a relative large typescript project, I'm using ts-node to run node testing and examples. As far as I understand, ts-node will compile ts files to js files and execute. Recently I heard about deno, which is a typescript runtime. I…
jerry
  • 1,196
  • 2
  • 9
  • 21
35
votes
1 answer

Node.js' __dirname & __filename equivalent in Deno

How can I get the directory & file name of the current module?. In Node.js I would use: __dirname & __filename for that
Marcos Casagrande
  • 37,983
  • 8
  • 84
  • 98
33
votes
2 answers

How can I avoid the "an import path cannot end with .ts extension" error in VSCode?

I'm using Visual Studio Code to write Deno programs. The import statement in Deno contains the .ts extension, e.g. import { Application } from "https://deno.land/x/oak/mod.ts"; which is marked as a problem in VS-Code, error code ts(2691): Despite…
jps
  • 20,041
  • 15
  • 75
  • 79
33
votes
5 answers

How can one check if a file or directory exists using Deno?

The Deno TypeScript runtime has built-in functions, but none of them address checking the existence of a file or directory. How can one check if a file or directory exists?
Amani
  • 16,245
  • 29
  • 103
  • 153
31
votes
3 answers

How do I read a local file in Deno?

I'm writing a word count program written in TypeScript that I'm trying to run in Deno. I'm invoking it with no arguments, just deno ./word_count.ts, so it should have the default read-only filesystem access. I was hoping that I might be able to use…
Jeremy
  • 1
  • 85
  • 340
  • 366
29
votes
4 answers

How to debug Deno in VSCode

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?
ClaireL
  • 443
  • 6
  • 10
24
votes
2 answers

Where can I see deno downloaded packages?

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…
Sambit
  • 7,625
  • 7
  • 34
  • 65
21
votes
3 answers

deno import JSON file as module

I have a simple file that imports a json: main.ts import json from './file.json' However, deno throws the following error when importing a json file: $ deno run main.ts Compile file:///home/path/to/project/main.ts error: Uncaught TypeError: Cannot…
Jankapunkt
  • 8,128
  • 4
  • 30
  • 59
21
votes
1 answer

How to exit in Deno? (analog of process.exit)

How to exit in Deno passing a status code? In Node.js you could use process.exit(), what is its Deno's counterpart ?
Francesco Borzi
  • 56,083
  • 47
  • 179
  • 252
20
votes
4 answers

How to use deno in production

I tried Deno (https://deno.land/) in local pc and some of its examples and we have to run the server before executing the APIs in the local environment. I need to host it in the server so that I can call that API when we request, but i don't know…
Nanda
  • 236
  • 2
  • 8
19
votes
6 answers

Getting values from Deno stdin

How can we get values from standard input in Deno? I don't know how to use Deno.stdin. An example would be appreciated.
benjamin Rampon
  • 1,316
  • 11
  • 18
18
votes
5 answers

How do I run an arbitrary shell command from Deno?

I want to run any arbitrary bash command from Deno, like I would with a child_process in Node. Is that possible in Deno?
Evan Conrad
  • 3,993
  • 4
  • 28
  • 46
18
votes
4 answers

How to delete runtime import cache in deno?

In node.js we can use delete require.cache[require.resolve(somePath)]; to delete the require cache in runtime. Is there a similar way to delete runtime import cache in deno?
xcatliu
  • 791
  • 7
  • 19
17
votes
3 answers

How to pass command line arguments to Deno?

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…
Ahmed Hammad
  • 2,798
  • 4
  • 18
  • 35
1
2 3
61 62