node-webkit 如何获取当前路径?

当node-webkit的应用运行时,会在临时目录里边产生一些临时文件,node-webkit就是在这个临时目录里边运行的,那么如何获取程序的真实路径?

阅读 3.5k
1 个回答

I want to build some data on the current directory ? But how to get the current directory?
console.log(__dirname)
I try that, but it doesn't work.
I want a little help.
Some temp files were built in the temp directory when it work on. How to get the real dirname?

answer:

Just so you know your project is compressed, packed, and concatenated into the binary. So when it runs it will unpack to a temp directory in order to be accessed.

Get path of project directory (temp dir):

console.log(process.cwd());

Get path of project binary:

var path = require("path");
console.log(path.dirname(process.execPath));
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进