如何将 config.js 文件添加到 nwjs 安装目录?

How to add a config.js file into nwjs install directory?

我使用 node-webkit-builder 来打包我的 nwjs 应用程序。 由于程序 运行 目录路径与安装目录路径不同( 运行 目录路径是这样的:C:\Users[用户名]\AppData\Local\Temp\nw7388_7201 )。我不知道如何在安装目录中添加我的 config.js 文件,并在我的 nwjs 应用程序中读取它。

此致。

检查这个:https://github.com/nwjs/nw.js/wiki/App#datapath

这是应用程序数据的公用文件夹。使用 gui.App.dataPath 你总是知道这个文件夹在哪里。

如果您需要知道您的可执行文件位于何处,请尝试:

var path = require('path');
var nwPath = process.execPath;
var nwDir = path.dirname(nwPath);

https://github.com/nwjs/nw.js/issues/1197