If you are looking for the path to the application source (i.e. the folder containing package.json ), you can use process.cwd() .
Regardless of which working directory the environment works when the node executable is running, it will install process.cwd() at the location of the application source. If the application is in the archive, cwd will point to a temporary folder where the source will be extracted.
It is important to note that process.cwd() can be changed during the start of the process.chdir(newPath) application and potentially other events, so you may want to keep the initial value when the application starts.
EDIT: To clarify, process.cwd() installed in the folder containing the actual package.json file that is used by the running application. Therefore, if you packed your application in an archive or executable file (zip, exe, nwz, nw, etc.), then before starting the application, nw.exe will extract the project files to a temporary directory. Thus, process.cwd() will point to this temporary folder not the location of the source archive or executable file.
ricovox
source share