I am not going to ask a question, but answer one, as I have found this advice nowhere online thus far and have just figured this out myself. It's good to share, right?
So on the command line, I did this:
sudo npm install -g cordova
sudo npm install -g phonegap
Which worked fine, but when I then ran either of these lines:
My-MacBook-Pro:~ username$ cordova
My-MacBook-Pro:~ username$ phonegap
I got these messages:
-bash: cordova: command not found
-bash: phonegap: command not found
Why? It turned out that the permissions on my /usr/local/lib directory were set to "everyone: No Access". I changed that to "everyone: Read only" and tried again.
My-MacBook-Pro:~ username$ cordova
My-MacBook-Pro:~ username$ phonegap
This time they worked! As a test I turned it back to "everyone: No Access" to see if it really was the problem. This time I got different messages:
-bash: /usr/local/bin/cordova: Permission denied
-bash: /usr/local/bin/phonegap: Permission denied
The outcome was the same though, I could not call either cordova or phonegap through the command line (I'm including these last two denial messages just in case anyone searches on them).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…