__dirname gives incorrect file path

I have been trying to use __dirname for fs.readFile, but __dirname doesn’t seem to return the proper file path. The path to my plugin repository should look something like

Documents/Obsidian Vault/.obsidian/plugins

But when I console.log(__dirname), it gives me


Any idea why it went wrong? Shouldn’t __dirname point to the path of my current code file?

Nothing went wrong, Obsidian is executing the code, the code is not called on it’s own.

In general, you should not use fs but rather the Vault API, or if you need access to hidden files the Adapter API.