我正在尝试获取可执行文件所在的目录,以便我可以访问与其相关的某些目录。 当我做类似的事情时
const executionDirectory = path.resolve(import.meta.dir)
,我得到/$bunfs/root
并且该目录下没有任何文件。
const executionDirectory = __dirname
为我提供了源目录,但没有提供可执行文件所在的位置。
我找到的解决方案是
process.execPath.split('/').slice(0, -1).join('/')
这似乎有效。 如果有更好的方法 - 请告诉我。