如何获取/$bunfs/root后面的实际目录

问题描述 投票:0回答:1

我正在尝试获取可执行文件所在的目录,以便我可以访问与其相关的某些目录。 当我做类似的事情时

const executionDirectory = path.resolve(import.meta.dir)
,我得到/$bunfs/root 并且该目录下没有任何文件。

const executionDirectory = __dirname
为我提供了源目录,但没有提供可执行文件所在的位置。

bun
1个回答
0
投票

我找到的解决方案是

process.execPath.split('/').slice(0, -1).join('/')

这似乎有效。 如果有更好的方法 - 请告诉我。

© www.soinside.com 2019 - 2024. All rights reserved.