D
Deno

help

newbie help on deploying first project to deno

Rruaan9/27/2022
I asked on deno github and was told to ask on discord: https://github.com/denoland/deno/discussions/16039 I wonder if someone could help me on this, im trying to deploy a mongodb nodejs project
GitHub
Deploy question regarding using npm specifiers · Discussion #16039 ...
I'm trying to learn how to upload my MongoDB project to Deno, under deployment I selected: index.js: "use strict" const Koa = require("koa") const Bodypa...
Jjavi9/27/2022
I’ve read over the GitHub thread and you’re basically trying to run deno as if it were node. First of all, require is not available (as you found out). To import packages form npm you have to use the special npm:<package> uri syntax (that is if you don’t use import maps, but under the hood you’re doing the same):
import iseven from "npm:iseven"
import iseven from "npm:iseven"
As seen in the docs, this is an unstable feature and requires the —unstable flag when running. Deno deploy doesn’t offer unstable APIs. Therefore, the code snippet you sent won’t be able to run on deno deploy until the npm specifier becomes stable. To run your code on deno deploy i advice you to either find native packages, try to write them yourself or wait. <:cookie_deno:1002977285734932480>
Rruaan9/27/2022
addin the flag —unstable it could work?
Jjavi9/27/2022
In your local build it will work. Nonetheless you cannot set that option on deno deploy, so that’s not a viable option
Rruaan9/27/2022
try to write them yourself or wait
wait what?
Jjavi9/27/2022
Take for example the mongodb package. Imagine you wanted to use it but you couldn’t on deno deploy. You could either write a driver yourself (requires skill and time) or wait for the npm thingy to be stable
Rruaan9/27/2022
I see, thank you, do you have any idea when it could be stable?
Jjavi9/27/2022
For the moment there’s no ETA, but due to the fact that it’s a highly requested, yet controversial, feature, it shouldn’t be a lot

Looking for more? Join the community!