Search code examples
javascriptgitgit-bashshortcut

Run javascript file with GitBash from shortcut


So usually to start my js files I right click and "Git Bash Here" then I node index.js.

Now I'm wondering if that can be done through a shortcut instead.

I've looked around everywhere and no methods worked for me but I have managed "C:\Program Files\Git\git-bash.exe" -c and it stays open.
Any help is appreciated.


Solution

  • Update: There's no need to build Node.js

    Since you already have Node.js installed, you can use the existing exe.

    You can use node.exe instead of Git Bash for creating a shortcut.

    Here are the steps I used (windows 10):

    • Go to C:/Program Files/nodejs.
    • Click Create shortcut for node.exe.
    • Right click on the shortcut and open Properties
    • Add the CLI args to the Target section. Before it was "C:\Program Files\nodejs\node.exe", but I changed it to "C:\Program Files\nodejs\node.exe" index.js. Also change the Start In to be the working directory you want.