Help us understand the problem. What is going on with this article?

cordovaでプラグインがインストールできなくなった

More than 3 years have passed since last update.

はじめに

cordovaで下記プラグインをインストールしようとしたところエラーが発生。
ごにゃごにゃやっているうちの他のエラーも発生しだしました。

なんとか、エラーがでないようにはなったので、
今後の自分の為にメモしておきます。

発生環境

cordova 4.3.1

エラーが発生したプラグイン

◎phonegap-plugin-push

https://github.com/phonegap-build/PushPlugin.git

cordova plugin add https://github.com/phonegap-build/PushPlugin.git

エラー内容

Failed to install 'com.phonegap.plugins.PushPlugin':TypeError: Uh oh!
Arguments to path.resolve must be strings
    at Object.posix.resolve (path.js:439:13)
    at Object.module.exports.framework.install (/usr/local/lib/node_modules/plugman/node_modules/cordova-lib/src/plugman/platforms/android.js:139:35)
    at installWrapper (/usr/local/lib/node_modules/plugman/node_modules/cordova-lib/src/platforms/platforms.js:77:32)
    at Object.ActionStack.process (/usr/local/lib/node_modules/plugman/node_modules/cordova-lib/src/plugman/util/action-stack.js:68:25)
    at handleInstall (/usr/local/lib/node_modules/plugman/node_modules/cordova-lib/src/plugman/install.js:576:20)
    at /usr/local/lib/node_modules/plugman/node_modules/cordova-lib/src/plugman/install.js:363:28
    at _fulfilled (/usr/local/lib/node_modules/plugman/node_modules/q/q.js:787:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/plugman/node_modules/q/q.js:816:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/plugman/node_modules/q/q.js:749:13)
    at /usr/local/lib/node_modules/plugman/node_modules/q/q.js:509:49

解決策

バージョン指定をしてインストールしたところ解消しました。

cordova plugin add https://github.com/phonegap-build/PushPlugin.git#2.4.0

◎google-analytics-plugin

プラグインを追加する際に下記のエラーが発生
プラグインを消して入れなおしても解消しない。

cordova plugin add com.danielcwilson.plugins.googleanalytics

エラー内容

SyntaxError: Unexpected string
    at Object.parse (native)
    at getJson (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/metadata.js:29:31)
    at Object.exports.save_fetch_metadata (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/util/metadata.js:56:24)
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/fetch.js:148:18
    at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:787:54)
    at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:816:30)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:749:13)
    at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:557:44
    at flush (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:355:11)

下記をやってみたら解消した。
・プロジェクト/packeage.jsonのcordovaPlugins{}の定義を削除
・プロジェクト/plugin/fetch.jsonを削除
・プラグインを一旦消して入れなおす
・0.6.1のバージョンをいれる

cordova plugin add com.danielcwilson.plugins.googleanalytics@0.6.1
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away