Sorikairo
Sorikairo3y ago

[Fixed] Package cannot read a file from itself when loaded from url

I have a package A, which has to read an html file located at the package's root, such as the following file tree exists : --- mod.ts --- swagger.html Locally it works, but as soon as I load it into Package B from deno.land/x/ it cannot find the swagger.html file. I tried reading it using either a relative path ./swagger.html or
const __dirname = path.dirname(path.fromFileUrl(import.meta.url));
const filePath = `${__dirname}/swagger.html`;
const swaggerHtml = await Deno.readTextFile(filePath);
const __dirname = path.dirname(path.fromFileUrl(import.meta.url));
const filePath = `${__dirname}/swagger.html`;
const swaggerHtml = await Deno.readTextFile(filePath);
Any clue on how to make it works ?
2 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Sorikairo
SorikairoOP3y ago
Smart to use fetch, let me try Working, thanks a lot @gimmebubbles

Did you find this page helpful?