ionic-team / ionic-cli

The Ionic command-line interface
MIT License
2k stars 653 forks source link

'ionic cordova plugin add' command can't install plugin #2836

Open mifkys opened 7 years ago

mifkys commented 7 years ago

Description:

After call 'ionic cordova plugin add <any plugin's GitHub url>' I've got error:

C:\apps\test>ionic cordova plugin add https://github.com/apache/cordova-plugin-statusbar.git

cordova plugin add https://github.com/apache/cordova-plugin-statusbar.git --save Error: Failed to fetch plugin https://github.com/apache/cordova-plugin-statusbar.git via registry. Probably this is either a connection problem, or plugin spec is incorrect. Check your connection and plugin name/version/URL. Error: cmd: Command failed with exit code 1 Error output: npm ERR! git clone C:\Users\user\AppData\Roaming\npm-cache_git-remotes\git-https-github-com-apache-cordova-plugin-statusbar-git-c66a3d92 C:\Users\user\AppData\Local\Temp\npm-17188-2e931d29\git-cache-f713dd3e\c45331b95555c5c77b4ed4ca690236a9b077ec4b: Cloning into 'C:\Users\user\AppData\Local\Temp\npm-17188-2e931d29\git-cache-f713dd3e\c45331b95555c5c77b4ed4ca690236a9b077ec4b'... npm ERR! git clone C:\Users\user\AppData\Roaming\npm-cache_git-remotes\git-https-github-com-apache-cordova-plugin-statusbar-git-c66a3d92 C:\Users\user\AppData\Local\Temp\npm-17188-2e931d29\git-cache-f713dd3e\c45331b95555c5c77b4ed4ca690236a9b077ec4b: error: cannot spawn sh: No such file or directory npm ERR! git clone C:\Users\user\AppData\Roaming\npm-cache_git-remotes\git-https-github-com-apache-cordova-plugin-statusbar-git-c66a3d92 C:\Users\user\AppData\Local\Temp\npm-17188-2e931d29\git-cache-f713dd3e\c45331b95555c5c77b4ed4ca690236a9b077ec4b: fatal: unable to fork npm ERR! git clone C:\Users\user\AppData\Roaming\npm-cache_git-remotes\git-https-github-com-apache-cordova-plugin-statusbar-git-c66a3d92 C:\Users\user\AppData\Local\Temp\npm-17188-2e931d29\git-cache-f713dd3e\c45331b95555c5c77b4ed4ca690236a9b077ec4b: npm ERR! Windows_NT 10.0.16299 npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "https://github.com/apache/cordova-plugin-statusbar.git" "--save" npm ERR! node v6.5.0 npm ERR! npm v3.10.3 npm ERR! code 128

npm ERR! Command failed: git -c core.longpaths=true clone C:\Users\user\AppData\Roaming\npm-cache_git-remotes\git-https-github-com-apache-cordova-plugin-statusbar-git-c66a3d92 C:\Users\user\AppData\Local\Temp\npm-17188-2e931d29\git-cache-f713dd3e\c45331b95555c5c77b4ed4ca690236a9b077ec4b npm ERR! Cloning into 'C:\Users\user\AppData\Local\Temp\npm-17188-2e931d29\git-cache-f713dd3e\c45331b95555c5c77b4ed4ca690236a9b077ec4b'... npm ERR! error: cannot spawn sh: No such file or directory npm ERR! fatal: unable to fork npm ERR! npm ERR! npm ERR! If you need help, you may report this error at: npm ERR! https://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request: npm ERR! C:\apps\test\node_modules\npm-debug.log

[ERROR] An error occurred while running cordova plugin add https://github.com/apache/cordova-plugin-statusbar.git --save (exit code 1).

Error returns on install any plugin from GitHub. For example:

ionic cordova plugin add https://github.com/appodeal/appodeal-cordova-plugin.git
ionic cordova plugin add https://github.com/appodeal/appodeal-cordova-plugin.git

But executing cordova plugin add ... without ionic works fine

Steps to Reproduce:

  1. Create new project
  2. Try to install plugin with ionic cordova plugin add ...

Output:

My ionic info:

@ionic/cli-utils : 1.15.1 ionic (Ionic CLI) : 3.15.1

global packages:

cordova (Cordova CLI) : 7.0.1

local packages:

@ionic/app-scripts : 3.0.1
Cordova Platforms  : android 6.2.3
Ionic Framework    : ionic-angular 3.7.1

System:

Android SDK Tools : 26.0.2
Node              : v6.5.0
npm               : 3.10.3
OS                : Windows 10

Environment Variables:

ANDROID_HOME : C:\dev\android-sdk

Misc:

backend : legacy

Other Information:

laloriru commented 7 years ago

I have the same issue. Wondering if it's solved already

sansan88 commented 7 years ago

same here:

@ionic/cli-utils  : 1.18.0
ionic (Ionic CLI) : 3.18.0

global packages:

cordova (Cordova CLI) : 7.1.0

local packages:

@ionic/app-scripts : 3.1.0
Cordova Platforms  : android 6.2.3 ios 4.4.0
Ionic Framework    : ionic-angular 3.9.2

System:

Node : v6.11.3
npm  : 3.10.10
OS   : Windows 10

Environment Variables:

ANDROID_HOME : not set

Misc:

backend : pro
uiktiomasfeliz commented 6 years ago

same here:

cli packages:

@ionic/cli-utils  : 1.19.0
ionic (Ionic CLI) : 3.19.0

global packages:

cordova (Cordova CLI) : 7.1.0

local packages:

@ionic/app-scripts : 3.1.5
Cordova Platforms  : android 6.3.0
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.1.1
Node              : v8.9.3
npm               : 5.6.0
OS                : Windows 10

Environment Variables:

ANDROID_HOME : D:\AndroidSDK

Misc:

backend : legacy
imhoffd commented 6 years ago

The true error is occurring deep in a tree of subprocesses.

npm ERR! Cloning into 'C:\Users\user\AppData\Local\Temp\npm-17188-2e931d29\git-cache-f713dd3e\c45331b95555c5c77b4ed4ca690236a9b077ec4b'... npm ERR! error: cannot spawn sh: No such file or directory npm ERR! fatal: unable to fork

This appears to be an issue only on Windows, unless someone says otherwise.

So, what setups do people have? Is everyone using Git for Windows? If so, what version? If not, please describe the shell program you're using, how git was installed, etc.

alex-polosky commented 6 years ago

If anyone else is having this issue, install git for windows from git scm, and make sure to use the option to use the bash shell for git. Then, right click in your ionic directory and click Git Bash Shell. From there, you can run your commands as normal.

This is a workaround that's worked for me for the time being.

lodhaaashish commented 6 years ago

I had same problem with running CMD on Windows 10 as an administrator.

Today I tried "Node.js command prompt" from start menu (run as Administrator), it got installed successfully this time.