nicetomytyuk
nicetomytyuk5mo ago

readFile path not found

I'm trying to use Deno.readFile but when is execute i get an error about wrong path. The files are like this: - db - dataservice.ts - config.sql - index.ts Then in daatabservice I try: private async getConfig(): Promise<string> { const decoder = new TextDecoder("utf-8"); const bytes = await Deno.readFile("./config.sql"); return decoder.decode(bytes); } Error handling product request: NotFound: Impossibile trovare il percorso specificato. (os error 3): readfile './config.sql' at async Object.readFile (e:\GitHub\GAB-Servizi-SB\eno_fs\30_fs.js:842:18)
7 Replies
raunioroo
raunioroo5mo ago
It's relative to current working dir (Deno.cwd), not module location. "./db/config.sql" might work in your case, depending on how you start deno.
nicetomytyuk
nicetomytyuk5mo ago
I start Deno in debug with F5 on VS Code It is run like: deno.EXE run --inspect-wait --allow-all .\docker\volumes\functions\cloud\index.ts
raunioroo
raunioroo5mo ago
You can create a module relative path by reading import.meta.url or something like that to get the module location, and use that to create an absolute path. I'm on mobile so can't dig an actuual example If i remember correctly, import.meta might even have a utility method to create a module-relative path that readFile can use. Or make it manually from import.meta.url
nicetomytyuk
nicetomytyuk5mo ago
Yeah I've just resolve it with import.meta
nicetomytyuk
nicetomytyuk5mo ago
I've use it like this:
No description
raunioroo
raunioroo5mo ago
The first dot here on the path should be the working directory. So looks like you'd need to include that whole ". /docker/volumes/..." thing, if you don't use the module relative thing
nicetomytyuk
nicetomytyuk5mo ago
Thank you raunioroo ❤
More Posts
Is there a way to read big files using something like .seek but with ending position as well?So, I'm doing a version of the billion line challenge in JS. I've already implemented a version withesbuild-deno-loader with npm private registryDid anyone used the esbuild-deno-loader with npm: specifier while using a private npm registry that how to load env variables from .env file in taskthe `source` shell command is not available. I tried ``` "tasks": { "my-task": "export .env &&Is there a way to specify a range and list from KV?```typescript const kv = await Deno.openKv(); kv.set(["parent", 1], "key1") kv.set(["parent", 2], "kPermissionDenied while using ioredis npm packageHello, I'm facing an issue with an npm library ioredis (https://github.com/redis/ioredis). For someIs there a way to obtain Deno.cron schedule info?Deploy lists the registered cron jobs with name, schedule, last run and next run. Is there a programVisual Studio Code Deno does not use node typesI'm trying to use the "esquery" node library with its types, but for any reason Deno ignores the typDrop permissionsI'd like to harden my deno app a bit, but specifying permissions manually gets repetitive. Is there New fresh project comes out of the box with errorsI created a new fresh project on linux, I am using VsCode and im getting many errors although the prIs there a deno function for inputting prompt reply without pressing enter?Normally, one has to press enter for the input to be accepted. I was wondering if there was a versio