Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我从 运行 Node 脚本/foo/bar,尽管脚本本身位于其他地方(例如node_modules)。有没有办法获取调用脚本的工作目录,即/foo/bar?
/foo/bar
node_modules
你想要的是process.cwd(),它返回 Node.js 进程的当前工作目录。
process.cwd()