Developing node-red standalone applications (Extra unanted user dir creation on app execution)

I have been working on node-red projects for past 7 months and now trying to make a node js based web app with node-red at its backend embedded within the project.
Steps I fallowed while making this application.

  1. Made a node.js project folder with npm init -y.
  2. Installed node red locally within the project folder.
  3. installed express npm package.
  4. Fallowed the [Embedding into an existing app](https://nodered.org/docs/user-guide/runtime/embedding) instruction.
  5. Tested the developed architecture by accessing the node-red running in the server hosted by means of node js.
  6. The node red editor was available at 'localhost:8000/red' url.
  7. When i try to use node js pkg module to make an standalone node red application i faced some errors which i solved by specifically mentioning the assets and scripts required for the package.

8.When i use the command pkg . in project directory terminal, i get the application.exe file for the developed nodejs project.
9.When i run this app i am able to access the node red terminal after launching the exe.
nodered_cloudcon


10. The issue i am facing is with respect to the control of the userDir property of the nodered.
11. Inorder to embed the node red within the node js app the settings were explicitly mentioned. and they were used when setting up the express app server.
12. Here the application is creating an extra folder with the nodered which needs to be avoided.
project structure
13. The project structure in above image already has a nodered folder which is supposed to be used as the user dir but the packaged application ends up creating a new node red folder.
14.
extra_folder
15. I have come across the posts with the problem solution of electron js but i would like to try this way and so i am looking out for valuable responses. kindly look into this case and aid me in this as this can help a lot. also i am not sure if any other solution exits do mention it as well.
Thank you all :slightly_smiling_face:

The 6th info line from the logs seems to indicate that you are creating that folder for use as the node-red user directory in the working directory of the running node-red process. You likely need to make a change in your settings.js file.

Hey Harold,
First of all thanks for taking your time and understanding the issue.
Adding on to your suggestion "that user directory setting" I am required to provide at the time of embedding node red.
Here let me attach the snippet of the code.



In the 15th line you can see i am providing the user directory which i have created inside my node js project structure.
I thought this would be used by my node js end standalone exe, but at the time of execution the app ends up creating extra folder even though it is packaged inside.
Let me know if i am unable to explain properly.
thanks

according to me the cause of the issue lies in snapshot file system architecture. Because the pkg module converts the filesystem to snapshot architecture.