D
Deno

help

readFile path not found

Nnicetomytyuk3/20/2024
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)
Rraunioroo3/20/2024
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.
Nnicetomytyuk3/20/2024
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
Rraunioroo3/20/2024
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
Nnicetomytyuk3/20/2024
Yeah I've just resolve it with import.meta
Nnicetomytyuk3/20/2024
I've use it like this:
No description
Rraunioroo3/20/2024
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
Nnicetomytyuk3/20/2024
Thank you raunioroo ❤

Looking for more? Join the community!

Recommended 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 versioSetting Deno.Command priority and affinity (on windows)Is it possible to set a tasks / commands priority and affinity directly? Code: ```ts await new DenoIs there a way to write a Deno.AtomicCheck that succeeds for any non-null versionstamp?You can write a Deno.AtomicCheck that fails if the versionstamp for a key-value pair in the KV storeImportTypeScript API + get value of `compilerOptions` with default options from `tsconfig.json`?Hello, I'm trying to figure out the proper way to do a few things: 1. What's the correct way to impHow to override the version from a dependency of a project's dependency from npmI'm currently using react-pdf as a dependency, react-pdf uses fontkit as a dependency, and fontkit uHow to publish global types with JSR?I was trying to republish my npm package with JSR via npm jsr package. It all went well with one excCaching results from APIHi, I'm currently working on a project where I get data from an API (https://www.robotevents.com/apiINTERNAL_SERVER_ERROR_2 / 500 response codeSeveral clients concurrently reported INTERNAL_SERVER_ERROR_2 with a 500 error on requests to a deplMy site seems to be under attackI receive a large amount of request last night. Does this mean my site is under attack...?Deno drizzle-kit migrate:pgI don't know if its drizzle error or Deno error... I saw path resolution problem, it is said `C:UseDoes V8 engine eventloop/threading model conflict with rust?hi, I am trying to embed deno's rusty_v8 into rust application. I am confused about the eventloop/th