
How To Use Node Js In Git Bash On Windows 11
Here is how to use node js in git bash terminal with a few steps on windows 11.

To use Node.js in Git Bash on Windows, you need to ensure that the path to Node.js is correctly set in your system's PATH environment variable or specifically added for Git Bash. Here are steps to resolve this issue:
Step 1: Verify Node.js Installation First, confirm that Node.js is installed correctly:
Open Command Prompt or PowerShell (not Git Bash) and type:
node -v
If this returns a version number, Node.js is installed; if not, you might need to install or reinstall Node.js.
Step 2: Add Node.js to System PATH
If Node.js works in Command Prompt but not in Git Bash, you might need to add the Node.js path manually or ensure it's in your system PATH:
- Locate Node.js Installation Path:
- Typically, Node.js installs in C:\Program Files\nodejs or C:\Program Files (x86)\nodejs.
- Add to PATH if not already included:
- Right-click on Start button, select System.
- Click on Advanced system settings on the right.
- Click Environment Variables.
- Under System Variables, find Path and click Edit.
- Click New and add the path where Node.js is installed (e.g., C:\Program Files\nodejs).
- Click OK to close all dialogs.
Step 3: Configure Git Bash
Git Bash might not read the Windows PATH directly due to how it's set up:
- Edit Git Bash's Profile:
- Open Git Bash.
- Edit or create the .bashrc or .bash_profile file:
echo 'export PATH=$PATH:/c/Program\ Files/nodejs' >> ~/.bashrc
- Or if using the default installation path:
echo 'export PATH=$PATH:/c/Program\ Files/nodejs' >> ~/.bash_profile
- Here, /c/ is how Git Bash translates C: in Windows file paths.
- Reload Bash or Restart Git Bash:
After adding the path, either:
- Type source ~/.bashrc or source ~/.bash_profile to apply changes immediately, or
- Simply close and reopen Git Bash.
Step 4: Verify in Git Bash
- Open Git Bash and type:
node -v
This should now display the version of Node.js installed on your system.
If these steps don't work, consider:
- Checking if there's a space in the path to Node.js, which might require quotation marks in the PATH setting.
- Ensuring you're using the correct drive letter (Git Bash uses forward slashes and /c/ for C:).
- Reinstalling Git for Windows if you suspect a configuration issue with Git Bash itself.
This should resolve the issue and allow you to use Node.js within Git Bash.