-bash:cordova:命令未找到;或-bash:phonegap:command not found [英] -bash: cordova: command not found; or -bash: phonegap: command not found

查看:2148
本文介绍了-bash:cordova:命令未找到;或-bash:phonegap:command not found的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不会问一个问题,但回答一个,因为我已经在网上找到这个建议,迄今为止,只是想出了自己。

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

我收到这些邮件:

-bash: cordova: command not found
-bash: phonegap: command not found

为什么?原来,我的/ usr / local / lib目录中的权限设置为everyone:No Access。

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

结果是一样的,不能通过命令行调用cordova或phonegap(我包括最后两个拒绝消息,以防任何人搜索他们)。

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).

推荐答案

我在Mac Os山狮。经过多次尝试,结果是解决方案很快。

I'm on Mac Os Mountain Lion. After several attempts, turns out the solution is pretty quick.

在安装Cordova之前,请确保您是要安装到的文件夹的所有者。打开终端并键入:

Before installing Cordova, make sure you are the owner of the folders it's going to install into. Open terminal and type:

sudo chown -R $USER /usr/local
sudo chmod -R 0775 /usr/local
npm install -g cordova

如果安装了新版本的node.js ,你仍然可能会得到一些错误。尝试删除npm缓存:

If you installed a new version of node.js, you could still get some error. Try deleting npm cache:

sudo npm cache clear
npm install -g cordova

然后键入 cordova 和好运;)

编辑:这似乎是在Maverick,Yosemite,El Capitan和Sierra工作

this seems to be working on Maverick, Yosemite, El Capitan and Sierra as well

这篇关于-bash:cordova:命令未找到;或-bash:phonegap:command not found的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆