本文介绍了将目录存储在node.js脚本运行的变量中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在Windows下的 C:\temp 中运行节点脚本,我该如何找出脚本运行的目录,(如何找到路径到脚本本身在文件系统中的位置?)



应该有效。


If I run a node script in C:\temp in Windows how do I find out what directory that script is running from, (how do I find the path to where the script itself is located in the filesystem?)

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

解决方案

__dirname should do the trick.

这篇关于将目录存储在node.js脚本运行的变量中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-29 06:12
查看更多