You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Git Bash中Phonegap命令找不到问题求助(Windows系统)

Troubleshooting "bash: phonegap: command not found" in Git Bash (Windows)

Hey Tim, sorry to hear you're stuck with this frustrating issue after reinstalling your tools—let's work through the most common fixes for this problem on Windows:

1. Make sure Git Bash recognizes your npm global package path

Phonegap and Cordova are installed as global npm packages, so Git Bash needs to know where their executable files are stored. Here's how to check and fix this:

  • First, run this command in Git Bash to find where npm saves global packages:
    npm config get prefix
    
    On Windows, this usually returns a path like C:\Users\YourUsername\AppData\Roaming\npm (Git Bash will display this as /c/Users/YourUsername/AppData/Roaming/npm).
  • Next, check if this path is included in your Git Bash system PATH:
    echo $PATH
    
  • If you don't see the npm prefix path in the output, add it temporarily to test:
    # Replace the path below with your actual npm prefix path
    export PATH="$PATH:/c/Users/YourUsername/AppData/Roaming/npm"
    
    Try running phonegap --version now—if it works, make this change permanent by adding the same export PATH line to your Git Bash profile:
    • Open (or create) the .bashrc or .bash_profile file in your user directory with a text editor:
      code ~/.bashrc
      
    • Paste the export PATH line into the file, save it, then restart Git Bash.

2. Confirm Phonegap is properly installed globally

Sometimes reinstalls don't complete as expected. Test if the command works outside Git Bash first:

  • Open Command Prompt or PowerShell (not Git Bash) and run:
    phonegap --version
    
  • If this also fails, reinstall Phonegap globally (use admin privileges if needed):
    npm install -g phonegap
    
    Repeat the same step for Cordova if you need it: npm install -g cordova

3. Check for admin-installed Node.js path issues

If you installed Node.js with admin rights, your global npm packages might be stored in C:\Program Files\nodejs instead of your user directory. Add this path to Git Bash's PATH too:

export PATH="$PATH:/c/Program Files/nodejs"

(Note: If your path has spaces, wrap it in quotes: export PATH="$PATH:\"/c/Program Files/nodejs\"")

4. Clean npm cache and do a fresh reinstall

Corrupted cache can cause installation glitches. Run these commands in Command Prompt (as admin if required):

npm cache clean --force
npm uninstall -g phonegap
npm install -g phonegap

Hopefully one of these steps gets your Phonegap commands working in Git Bash again!

内容的提问来源于stack exchange,提问作者Temujin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 03:56:30