togakangaroo
togakangaroo
DDeno
Created by togakangaroo on 11/8/2024 in #help
How to note require the node: prefix
deno 2.0.3 (stable, release, x86_64-unknown-linux-gnu)
v8 12.9.202.13-rusty
typescript 5.6.2
deno 2.0.3 (stable, release, x86_64-unknown-linux-gnu)
v8 12.9.202.13-rusty
typescript 5.6.2
I'm trying to see if I can run some part of our existing node codebase in deno for the jupyter compatability and at this point am down to this issue - our code doesn't use the node: specifier. I am not looking to move everything over to Deno (big codebase, loads of devs, etc) just to use it as an alternate runtime for doing certain things. I see mentions of node-compat mode in the past, and even more recent posts about how you can do this, and how it already happens within npm packages. Can I actually do it within my code however? I no longer see any flags for it
$ ~/.deno/bin/deno eval --unstable-sloppy-imports "import { existsSync } from 'fs"
error: Relative import path "fs" not prefixed with / or ./ or ../
hint: If you want to use a built-in Node module, add a "node:" prefix (ex. "node:fs").
$ ~/.deno/bin/deno eval --unstable-sloppy-imports "import { existsSync } from 'fs"
error: Relative import path "fs" not prefixed with / or ./ or ../
hint: If you want to use a built-in Node module, add a "node:" prefix (ex. "node:fs").
1 replies
DDeno
Created by togakangaroo on 11/3/2024 in #help
Cannot import when index.d.ts file
This is largely a question about node compatibility as what I really want is to run my existing large node/typescript project in Deno so that I can get good jupyter integration. I've managed to figure things out to where they mostly work but am running into issues where my existing code uses the npm type-fest package to provide advanced typescript types. So as an example, I have the following import in my code
import { LiteralUnion } from 'type-fest'
import { LiteralUnion } from 'type-fest'
I can't for the life of me get this to work. Lets set the issue of node-compatibility aside as I'm not sure how relevant it is here. I get the following in just the straight-up repl as well
gmauer:/tmp$ /home/gmauer/.deno/bin/deno repl
Deno 2.0.3
exit using ctrl+d, ctrl+c, or close()
>
import { LiteralUnion } from 'npm:type-fest'
> Download ⣯ [00:05]
- npm:type-fest
Download ⣽ [00:06] 1/2
- npm:type-fest/-/type-fest-4.26.1.tgz


Uncaught TypeError: [ERR_MODULE_NOT_FOUND] Cannot find module 'file:///home/gmauer/.cache/deno/npm/registry.npmjs.org/type-fest/4.26.1/index.js' imported from 'file:///tmp/$deno$repl.ts'
at async <anonymous>:1:47
gmauer:/tmp$ /home/gmauer/.deno/bin/deno repl
Deno 2.0.3
exit using ctrl+d, ctrl+c, or close()
>
import { LiteralUnion } from 'npm:type-fest'
> Download ⣯ [00:05]
- npm:type-fest
Download ⣽ [00:06] 1/2
- npm:type-fest/-/type-fest-4.26.1.tgz


Uncaught TypeError: [ERR_MODULE_NOT_FOUND] Cannot find module 'file:///home/gmauer/.cache/deno/npm/registry.npmjs.org/type-fest/4.26.1/index.js' imported from 'file:///tmp/$deno$repl.ts'
at async <anonymous>:1:47
This seems to be because whats inside of there is index.d.ts not index.js Interestingly, I can't do npm:type-fest/index.d.ts either as it seems to error out at the 8th line which begins with export type. I'm honestly not sure if this is a bug, an expected behavior, a bug in type-fest or what. It doesn't seem like a type-fest issue as they don't seem to be doing anything wrong here, this is all perfectly normal typescript and idioms. I also know they've had some issues with deno in the past but they were resolved years ago
1 replies