如何找到一个node.js程序的当前工作目录来存储一个变量? [英] How do I find the current working directory of a node.js program to store in a variable?

查看:193
本文介绍了如何找到一个node.js程序的当前工作目录来存储一个变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望存储目录中的node.js脚本已经从一个变量中运行,我该怎么做?

fs模块文档似乎并不能解决这个问题。

__ dirname : http://nodejs.org/docs/latest/api/globals.html#globals_dirname


I wish to store the directory my node.js script has been run from in a variable, how would I do this?

The fs module documentation doesn't seem to hold an answer to this.

解决方案

What you are looking for is __dirname: http://nodejs.org/docs/latest/api/globals.html#globals_dirname

这篇关于如何找到一个node.js程序的当前工作目录来存储一个变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆