jradxl
jradxl
DDeno
Created by jradxl on 9/30/2024 in #help
Deno import use for local files?
I'm using Deno (v2) as an alternative to Bash Scripting, and I'm looking for an equivalent to Bash's Source statement, to include any common functions I might write. Of course, import { something } from "./myfunctions,ts" works fine as a relative path, And an absolute path works too, import { something } from "/home/john/.deno/mylibraries/myfunctions.ts". But this hard codes my username in the path. I have found that dynamic imports can be used to avoid this , const myhome = Deno.env.get("HOME") const libpath = myhome + "/.deno/mylibraries/myfunctions.ts"; const myfunctions = await import(libpath); I also thought that a webserver might work, import { something } from "http://localhost/myfunctions.ts"; and it nearly does, shown by the intelisense in vscode, but running gives the error, Expected a JavaScript or TypeScript module, but identified a Unknown module Are their any other/better ways of importing modules? I don't want to make my files public so don't want to use Github Perhaps I could self-host Gitea But all seem overly complex compared to Bash's Source command. Suggestions, please?
9 replies