ionic-2 native youtube video player plugin failed

2019-05-27 12:49发布

问题:

hi i am building an ionic-2 app which shows some you tube videos content, i researched on the ionic native docs https://ionicframework.com/docs/native/youtube-video-player/

when i tried to install this plugin

`ionic cordova plugin add https://github.com/JonSmart/CordovaYoutubeVideoPlayer`

i am getting error on my console

error msg

Error: Failed to fetch plugin https://github.com/JonSmart/CordovaYoutubeVideoPlayer 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 4294963228 Error output:
npm ERR! addLocal Could not install C:\Users\***\AppData\Local\Temp\npm-1048-6f63d401\git-cache-cc20a6f9\2a0cc8f3790b584ed1aae3927d03f7213e90c9d0
npm ERR! Windows_NT 6.1.7600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\***\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "https://github.com/JonSmart/CordovaYoutubeVideoPlayer" "--save"
npm ERR! node v4.5.0
npm ERR! npm  v3.9.0
npm ERR! code EISDIR
npm ERR! errno -4068
npm ERR! syscall read

npm ERR! eisdir EISDIR: illegal operation on a directory, read
npm ERR! eisdir This is most likely not a problem with npm itself
npm ERR! eisdir and is related to npm not being able to find a package.json in
npm ERR! eisdir a package you are trying to install.

i also refereed git hub link here https://github.com/JonSmart/CordovaYoutubeVideoPlayer

but there are no issues present.

Any Hints! thanks!

回答1:

There seem to be issues with cordova plugins and cordova version 7.0.0 +. The plugins now need to include a package.json. For example check this issue.

The youtube plugin does not have package.json

I suggest you downgrade the cordova version to below 7.0.0 till it is fixed.

npm install -g cordova@version_number