Managing Dependencies

Learn how to manage dependencies in Deno using a single JavaScript file.

Exporting dependencies

If we have used other tools, or even Node.js, we might feel that it isn’t very intuitive to have URLs all around the code. We can also argue that by directly writing URLs in our code, we might cause problems, such as having two different versions of the same dependency or having typos in the URL.

Deno solved this problem by getting rid of complex module resolution strategies and using plain JavaScript and absolute imports instead.

The proposed solution to keep track of dependencies, which is no more than a suggestion, is to use a file that exports all the required dependencies and place them in a single file that contains URLs. Let’s see it in action.

We create a file called deps.js and add our dependencies there, exporting the ones we need:

Get hands-on with 1200+ tech skills courses.