admin管理员组文章数量:1355221
I'm trying to figure out how to predict paths within the code in an electron packaged app with asar flag.
Using windows (one exe file) and mac (one .app package folder) - each finally includes an asar file, to contain the node scripts.
I want to access the folder where the exe is on windows, and the current package app parent folder.
/Application/my app tools/tool.app -> path to 'my app tools'
C:\Program Files\my app tools\tool\ -> path to 'my app tools'
Using __dirname
and traversing down does not help, since there is a different amount of subfolders on win and mac.
Any help is greatly appreciated.
seems to be related to How to get the original path of a portable Electron app?
I'm trying to figure out how to predict paths within the code in an electron packaged app with asar flag.
Using windows (one exe file) and mac (one .app package folder) - each finally includes an asar file, to contain the node scripts.
I want to access the folder where the exe is on windows, and the current package app parent folder.
/Application/my app tools/tool.app -> path to 'my app tools'
C:\Program Files\my app tools\tool\ -> path to 'my app tools'
Using __dirname
and traversing down does not help, since there is a different amount of subfolders on win and mac.
Any help is greatly appreciated.
seems to be related to How to get the original path of a portable Electron app?
Share Improve this question edited Aug 3, 2018 at 10:43 BananaAcid asked Jul 23, 2018 at 5:58 BananaAcidBananaAcid 3,5111 gold badge38 silver badges41 bronze badges 1- I collected some path data for windows and mac - see here github./BananaAcid/Simple-Electron-Kiosk/blob/master/… – BananaAcid Commented Aug 3, 2018 at 18:05
1 Answer
Reset to default 7Taking a look at the documentation here will provide you the needed opportunity.
Using it from the main process will look like this:
const {app} = require('electron')
console.log('Your App Path: + ' app.getAppPath())
and if you want to use it in a renderer process take a look at this:
const {remote} = require('electron')
console.log('Your App Path: ' + remote.app.getAppPath())
本文标签: javascriptNodeJSelectron pathsStack Overflow
版权声明:本文标题:javascript - NodeJS + electron paths - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743983418a2571174.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论