Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Reading the documentation, it seems that `require` at the top-level should be possible under one of three scenarios:

(1) the file extension is "cjs",

(2) there is a package.json file with "type" set to "commonjs", or

(3) a require function is created with createRequire

https://docs.deno.com/runtime/fundamentals/node/#commonjs-su...

Seems like the code from the article will run as-is with either of the first two options. In any case, this is what I meant by Deno not being able run the code "unless one explicitly configures" it.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: