Closed bjesuiter closed 1 year ago
Update: It works when directly starting main.ts
!
deno run --unstable -A main.ts
What is different when running the fresh project through the dev() server?
I'm also seeing a similar issue but with mongodb driver.
When using the mongodb driver in dev mode, I got the following error:
error: Uncaught (in promise) Error: Cannot find module 'crypto'
Require stack:
- /Users/steve/Library/Caches/deno/npm/registry.npmjs.org/mongodb/4.10.0/lib/operations/add_user.js
- /Users/steve/Library/Caches/deno/npm/registry.npmjs.org/mongodb/4.10.0/lib/admin.js
- /Users/steve/Library/Caches/deno/npm/registry.npmjs.org/mongodb/4.10.0/lib/index.js
- /Users/steve/Library/Caches/deno/npm/registry.npmjs.org/mongodb/4.10.0/lib/index.js
at Function.Module._resolveFilename (deno:ext/node/02_require.js:615:17)
at Function.Module._load (deno:ext/node/02_require.js:447:29)
at Module.require (deno:ext/node/02_require.js:658:21)
at require (deno:ext/node/02_require.js:789:18)
at Object.<anonymous> (file:///Users/steve/Library/Caches/deno/npm/registry.npmjs.org/mongodb/4.10.0/lib/operations/add_user.js:4:16)
at Object.<anonymous> (file:///Users/steve/Library/Caches/deno/npm/registry.npmjs.org/mongodb/4.10.0/lib/operations/add_user.js:73:4)
at Module._compile (deno:ext/node/02_require.js:719:36)
at Object.Module._extensions..js (deno:ext/node/02_require.js:752:12)
at Module.load (deno:ext/node/02_require.js:636:34)
at Function.Module._load (deno:ext/node/02_require.js:493:14)
@steverandy Maybe your problem is a little different to mine.
Deno currently does not import peer dependencies for npm packages automatically, so you have to add an empty 'import {} from "npm:your-missing-packet@version"' to somewhere in your runtime.
You can look my other issue here for details: https://github.com/denoland/deno/issues/16013
My problem is that I get this error about a missing global which is cryptic to me bc. I don't know which rubbing file is causing it.
I suspect, it's the fresh dev mode somehow, by maybe isolating my main Programm more.
But! maybe I'm wrong here that your problem is different to mine. Does your code work when running main.ts directly, like with my code?
@bjesuiter
Yes. It works when I run main.ts directly. No errors.
I also tried adding import {} from "npm:mongodb";
to dev.ts
and now it also works in dev.
Do you know why it behaves this way? Is there a documentation around this behavior? Thanks!
@steverandy Yes, you can read the thread in my other issue: https://github.com/denoland/deno/issues/16013
The reason seems to be that deno doesn't load peer dependencies yet,
so the mongodb client gets not automatically loaded into the runtime when it's needed.
Maybe you have some import from "npm:mongodb
somewhere in your main.ts but not in the dev.ts runpath,
so that the mongo-db client was already available on the runtime when starting from main.ts.
Closing as duplicate of https://github.com/denoland/fresh/issues/978
Hello there,
What do I want to do
I tried to run the following in the default index.tsx page:
Unfortunately, this fails with:
The Error Message
Further Information
This error appears to come from the package
@planetscale/database
which is setup in@src/db/index.ts
However, it actually does arise first when adding the query:
More Analysis
I can run the following sucessfully:
Command:
File Content of
./scripts/db/list-pets.ts
:Last Question
Where is the difference from running this code in standalone deno or running this query inside the index.tsx with the fresh Framework?