8

Problem description:


I have an electron application and I need to add the application to user environment variables after users install my application, so that they can run commands like this my-electron-app <command> [<args>] in the terminal to start my electron application.

I could not find a way to do this programmatically using nodejs. VSCode, hyper and atom are the three electron apps ( that I know of ) who add the application path to user environment variables after users install the application.

I'm using electron builder to build an NSIS installer. I couldn't find any options there either that serve the purpose.

Question:


How can I add my electron application to user environment variables after users install my application on their system, so that they can launch my electron app from terminal by running commands like this my-electron-app start?

Nishkal Kashyap
  • 960
  • 7
  • 17
  • Possible duplicate of [How do I install a module globally using npm?](https://stackoverflow.com/questions/5817874/how-do-i-install-a-module-globally-using-npm) –  Nov 23 '18 at 00:42
  • I suppose you could generate a bash script on first launch and save it to `/usr/local/bin/` or similar. On macOS you can simply use `open -a YourApp yourFile`. – mb21 Jan 26 '19 at 10:29
  • Any update? Did you find any solution? I'm facing the same problem. – h-sifat Nov 04 '22 at 02:32

1 Answers1

-1

I am blindly guessing here since I have simply browsed through the code for a couple of minutes: There seems to be a post install step which is maybe also used in Hyper here somehow. This script places a file in a folder that is probably in the user's PATH. More about the PATH environment variable here.

Rolf
  • 1,129
  • 11
  • 27