question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to configure DENO_DIR for dynamic imports?

See original GitHub issue

Thanks for the Deno runtime! I came running back to Vercel because Deno Deploy doesn’t do dynamic imports and vercel-deno is a lifesaver 😸

Unfortunately, I still can’t get dynamic imports working because I get this runtime error: TypeError: Could not create TypeScript compiler cache location: "/var/task/.deno/gen/file/var/task/commands/1"

I saw that the solution was to simply set the DENO_DIR variable to something under /tmp. Unfortunately, simply setting that variable either on Vercel’s settings or with the hashbang wasn’t enough to change the directory.

This is what I have right now as my hashbang, the env var as well as the two includes for files I want to import which work fine:

#!/usr/bin/env DENO_DIR=/tmp/.deno deno run --include-files ../util/**/* --include-files ../commands/**/*

Is there any other way I can configure DENO_DIR?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
5310commented, Aug 30, 2021

My functions are already working dynamically with v1.0

Thank you again for the fix and ofc for the runtime! 🏆

1reaction
TooTallNatecommented, Aug 29, 2021

Ok, well it’s a simple change in the bootstrap file to make it work (right now DENO_DIR is always set in that file before invoking deno. I think we can make it only set it by default, and allow to overwrite via env var).

Example: https://vercel-deno-o1u7gi9m0-tootallnate.vercel.app/api/main

You can see in the Function invocation logs that the source files are downloaded / compiled at runtime (which leads to a rather slow cold boot):

Screen Shot 2021-08-28 at 7 30 12 PM

That said, I’d still like overwriting DENO_DIR be supported, so I’ll turn this into a proper PR next.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic imports - The Modern JavaScript Tutorial
First, we can't dynamically generate any parameters of import . The module path must be a primitive string, can't be a function call....
Read more >
add --allow-import=<allow_list> for checking dynamic ... - GitHub
Context: Currently loading dynamic imports or worker code requires --allow-read and/or ... Enable Deno namespace by default in Workers #8174.
Read more >
How to Dynamically Import ECMAScript Modules
You can import modules dynamically if you use import as a function — import(pathToModule) — a feature available starting ES2020.
Read more >
Webpack and Dynamic Imports: Doing it Right - Medium
Dynamic imports : the basics ... The above code will load the foo module at runtime, and resolving it, will log the default...
Read more >
How to use Dynamic Imports for Modules - JavaScript Tutorial
In today's video I'll be showing you how to use Dynamic Imports for your modules in JavaScript - this allows you to dynamically...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found