Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

n00b struggling with deploying fresh project with deno kv #2443

Closed
crowlsyong opened this issue May 21, 2024 · 1 comment
Closed

n00b struggling with deploying fresh project with deno kv #2443

crowlsyong opened this issue May 21, 2024 · 1 comment

Comments

@crowlsyong
Copy link

crowlsyong commented May 21, 2024

I'm playing around with building a URL shortener (repo) via fresh framework and deno kv. I am using github actions and I can't fix the build step, here is the error:

error: Uncaught (in promise) TypeError: Deno.openKv is not a function export const kv = await Deno.openKv(); ^ at file:///home/runner/work/advrk-io/advrk-io/services/database.ts:5:30 Error: Process completed with exit code 1.

Direct link to database file in my repo

I have tried adding the --unstable and --unstable-kv to the project but no dice.

I have done some research: I have looked through the Deno KV docs and Deno Deploy docs and I couldn't seem to find a solution. I also googled my exact error and couldn't find a solution.

Obligatory "it works on my machine though" comment (because it does work locally on my machine lol).

I am a n00b, my code sucks, you will not offend me by telling me that my code is garbage. Any help is appreciated. I'm happy to bring this issue to the Deno KV github page if that is a more appropriate fit.

❤️💻

@crowlsyong crowlsyong changed the title n00b struggling with deploy fresh project with deno kv May 21, 2024
@marvinhagemeister
Copy link
Collaborator

marvinhagemeister commented May 21, 2024

Passing arguments AFTER deno task myscript will not pass the arguments to Deno, but to the invoked task instead. In the linked CI output this command is called:

deno task build --unstable-kv

# which gets turned to this
deno run -A dev.ts build --unstable-kv

This passes the --unstable-kv flag to the dev.ts script, but not to deno run itself. Interestingly, that's already done correctly for the start task.

You can resolve this error by updating the build task inside deno.json:

  {
    "tasks": {
      "start": "deno run -A --watch=static/,routes/ --unstable-kv dev.ts",
-     "build": "deno run -A dev.ts build"
+     "build": "deno run -A --unstable-kv dev.ts build"
     }
  }

And then you can keep calling deno task build in your CI. I'd recommend doing the same change to the preview task.

crowlsyong added a commit to crowlsyong/advrk-io that referenced this issue May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants