2014年4月24日木曜日

プラグイン追加に於けるエラーについて Cordova(PhoneGap)

今回は、Cordovaプラグイン追加の際に、発生するエラーについて、対処方法をまとめてみました。

■gitがインストールされていない、またはpathが通っていない時に発生するエラー
>cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git
Fetching plugin "https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git" via git clone
Error: "git" command line tool is not installed: make sure it is accessible on your PATH.

・対処方法
cordovaは、プラグインを追加する時に、gitを利用しています。
事前に、gitをインストールする必要があります。

1.以下のURLからダウンロードして、gitをインストールします。
http://git-scm.com/downloads

2.インストール先に対してpathを通します。
システムのプロパティから[詳細設定]-[環境変数]-[システム環境変数]の「path」に
「*****\Git\cmd;」を追加します。

3.プラグイン追加を再実行します。
>cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git
Fetching plugin "https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git" via git clone
Installing "org.apache.cordova.file" for android


■gitの依存関係が原因で発生するエラー
>cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git
Fetching plugin "https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git" via git clone
Error: Command failed: fatal: could not create work tree dir '*****\AppData\Local\Temp\plugman\git\1398234116751'.: No such file or directory

・対処方法
1.gitの作業ディレクトリを作成します。
mkdir *****\AppData\Local\Temp\plugman\git

2.プラグイン追加を再実行します。
>cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git
Fetching plugin "https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git" via git clone
Installing "org.apache.cordova.file" for android


■プロキシ環境で発生するエラー
[その1]
>cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git
Fetching plugin "https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git" via git clone
Error: Command failed: Cloning into '*****\AppData\Local\Temp\plugman\git\1398234984182'...
fatal: unable to access 'https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git/': Failed connect to git-wip-us.apache.org:443; No error

・対処方法
1.gitにプロキシの設定を追加します。
>git config --global http.proxy http://プロキシサーバのURL:ポート番号
>git config --global https.proxy https://プロキシサーバのURL:ポート番号

2.設定内容を確認します。
>git config --global --list
http.proxy=http://プロキシサーバのURL:ポート番号
https.proxy=https://プロキシサーバのURL:ポート番号

3.プラグイン追加を再実行します。
>cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git
Fetching plugin "https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git" via git clone
Installing "org.apache.cordova.file" for android

※Gitのプロキシ設定について
設定内容の確認
>git config --global --list

設定の追加
>git config --global http.proxy http://プロキシサーバのURL:ポート番号
>git config --global https.proxy https://プロキシサーバのURL:ポート番号

設定の削除
>git config --global --unset ***


[その2]
>cordova plugin add org.apache.cordova.file
Fetching plugin "org.apache.cordova.file" via plugin registry
Error: Failed to fetch package information for org.apache.cordova.file

・対処方法
1.以下の設定ファイルを編集します。
*****\AppData\Roaming\npm\node_modules\cordova\node_modules\plugman\src\registry\registry.js

以下のようにプロキシサーバーのURLを追加します。

var p = settings.proxy || http://プロキシサーバのURL:ポート番号
var sp = settings['https-proxy'] || p
opts.proxy = remote.protocol === "https:" ? sp : p

2.プラグイン追加を再実行します。
>cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git
Fetching plugin "https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git" via git clone
Installing "org.apache.cordova.file" for android


0 件のコメント:

コメントを投稿