sodium icon indicating copy to clipboard operation
sodium copied to clipboard

error: Uncaught (in promise) ReferenceError: __dirname is not defined

Open subhash-malireddy opened this issue 1 year ago • 5 comments

Error Description

error: Uncaught (in promise) ReferenceError: __dirname is not defined
    at Object.g.ready.r.useBackupModule (https://deno.land/x/[email protected]/dist/browsers/sodium.js:1:943)
    at https://deno.land/x/[email protected]/dist/browsers/sodium.js:1:497208

Quick finding with Orama Ai on Deno docs

const __filename = new URL(import.meta.url).pathname;
const __dirname = __filename.substring(0, __filename.lastIndexOf('/'));

subhash-malireddy avatar Oct 18 '24 00:10 subhash-malireddy

According to https://docs.deno.com/runtime/fundamentals/node/

We should just have to replace:

  • __filename with import.meta.filename
  • __dirname with import.meta.dirname

Tried doing it myself but I can't figure out how to build the project to prove it works...

Pretty sure it's all that's needed. Did the same with another library with the same issue and it worked.

mash8 avatar Nov 04 '24 00:11 mash8

Sounds like the solution! You are very welcome to create a PR :)

eliassjogreen avatar Nov 04 '24 20:11 eliassjogreen

How to solve this problem?

OY6090 avatar Nov 11 '24 07:11 OY6090

I'm working on a fix. Gonna take a bit of time...

You can temp fix it by staying on deno 1.x

mash8 avatar Nov 11 '24 07:11 mash8

Any update?

soundstep avatar Mar 19 '25 16:03 soundstep