To Install and Run Node/React app as an Exe file We’ll need the following prerequisites:
- NodeJS and npm installed. https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
- A demo Node App https://medium.com/@diogo.fg.pinheiro/simple-to-do-list-app-with-node-js-and-mongodb-chapter-1-c645c7a27583
- Inno Setup Compiler https://jrsoftware.org/isdl.php
- Bat to exe converter https://bat-to-exe-converter-x64.en.softonic.com/
Step 1 : Make Sure the Node app is installed and ready to launch.
- Run the install command mentioned in the documentation of the node app.
Usually it’s either NPM init or YARN install - Once the installation is done and all the required modules are installed, try running the app with the command mentioned in the documentation
Usually it’s NPM start or YARN run
Step 2 : Create a exe file that executes the run command to start the application
- Open BAT to EXE converter
- Type the run command used to start the app
- Click convert to convert it into an exe file, we can also add an icon for a better looking exe file.
- Add this line on top to open the cmd in background
if not DEFINED IS_MINIMIZED set IS_MINIMIZED=1 && start "" /min "%~dpnx0" %* && exit
Step 3 : Create a setup file to extract the files and create a shortcut on desktop and start menu
- Open inno setup compiler
- Select “new script” and fill in the project details.
- Let the application destination base be default or customise it if needed.
This will be your installation directory. - Choose the exe file we created on step 2 as main executable file
Also choose “add folder” and choose the root folder consisting all the required files and exe file. - Choose your setup name, output folder and setup icon.
- Click on finish to generate the setup file
Step 4 : Create a installer for systems without nodeJS Pre installed.
- Go to your setup output directory from step 3
- Download the latest version of node installer from here
https://nodejs.org/en/download/ - Group them in a folder named “bin” like this
- Open bat to exe converter and paste the following commands
cd bin/
start “YourApplicationNameHere”.exe
start node.msi
- Convert it to an exe and place it outside the bin folder
- Compress the bin folder and this exe as a zip.
This Zip can be shared with anyone who doesn’t have prior programming experience or nodeJS installed in their system. The installer installs both NodeJs and the app and creates shortcuts on the desktop and start menu. This shortcut will open up the application in the browser.