简体   繁体   English

Cordova:全局安装后找不到命令

[英]Cordova: command not found after installing globally

I try to install Cordova in macOS Mojave. 我尝试在macOS Mojave中安装Cordova。 I run the following command to install globally. 我运行以下命令以全局安装。 It is installed successfully npm i -g cordova 它已成功安装npm i -g cordova

but when I check the version using cordova --version , It gives me the error "cordova: command not found". 但是当我使用cordova --version检查版本时,出现错误“ cordova:找不到命令”。

and also when I try to get the location using which cordova , It returns nothing. 以及当我尝试获取使用which cordova的位置时,它什么也不返回。

Refer this great write up: http://blog.webbb.be/command-not-found-node-npm/ 请参考以下出色的文章: http : //blog.webbb.be/command-not-found-node-npm/

This can happen when npm is installing to a location that is not the standard and is not in your path. 当npm安装到非标准位置并且不在您的路径中时,可能会发生这种情况。

To check where npm is installing, run: npm root -g 要检查npm的安装位置,请运行: npm root -g

It SHOULD say /usr/local/lib/node_modules , If it doesn't then follow this: 它应该说/usr/local/lib/node_modules ,如果没有,请遵循以下步骤:

Set it to the correct PATH: 将其设置为正确的路径:

  • run: npm config set prefix /usr/local 运行: npm config set prefix /usr/local

  • Then reinstall your npm package(s) with -g: npm install -g cordova etc 然后使用-g重新安装您的npm软件包: npm install -g cordova

If this doesn't work then try adding the global path of cordova(where it got installed) to your $PATH variable. 如果这不起作用,请尝试将cordova(安装位置)的全局路径添加到$PATH变量中。

尝试以root身份安装:

sudo npm i -g cordova 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM