$ ionic cordova prepare android
? Platform android is not installed! Would you like to install it? Yes
> cordova platform add android --save
{ Error: npm: Command failed with exit code 1 Error output:
npm ERR! code ENOLOCAL
npm ERR! Could not install from "android" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/kiya/.npm/_logs/2019-04-09T04_27_30_999Z-debug.log
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-common/src/superspawn.js:125:23)
at ChildProcess.emit (events.js:189:13)
at maybeClose (internal/child_process.js:970:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
stderr:
'npm ERR! code ENOLOCAL\nnpm ERR! Could not install from "android" as it does not contain a package.json file.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /home/kiya/.npm/_logs/2019-04-09T04_27_30_999Z-debug.log\n',
code: 1 }
[ERROR] An error occurred while running subprocess cordova.
cordova platform add android --save exited with exit code 1.
Re-running this command with the --verbose flag may provide more
information.
? Platform android is not installed! Would you like to install it? Yes
> cordova platform add android --save
{ Error: npm: Command failed with exit code 1 Error output:
npm ERR! code ENOLOCAL
npm ERR! Could not install from "android" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/kiya/.npm/_logs/2019-04-09T04_27_30_999Z-debug.log
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-common/src/superspawn.js:125:23)
at ChildProcess.emit (events.js:189:13)
at maybeClose (internal/child_process.js:970:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
stderr:
'npm ERR! code ENOLOCAL\nnpm ERR! Could not install from "android" as it does not contain a package.json file.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /home/kiya/.npm/_logs/2019-04-09T04_27_30_999Z-debug.log\n',
code: 1 }
[ERROR] An error occurred while running subprocess cordova.
cordova platform add android --save exited with exit code 1.
Re-running this command with the --verbose flag may provide more
information.
はてさて何が起こったのか…
とりあえずインストールマニュアルを見ると(マニュアル見ながらインストールしろ!と自分に突っ込みながら^^;)Ionic3 のときとはちょっと違っていて環境変数が不足しているよう…
# Android SDK のパス
export ANDROID_SDK_ROOT=${HOME}/Android/sdk
# avdmanager, sdkmanager
export PATH=${PATH}:$ANDROID_SDK_ROOT/tools/bin
# adb, logcat
export PATH=${PATH}:$ANDROID_SDK_ROOT/platform-tools
# emulator
export PATH=${PATH}:$ANDROID_SDK_ROOT/emulator
export ANDROID_SDK_ROOT=${HOME}/Android/sdk
# avdmanager, sdkmanager
export PATH=${PATH}:$ANDROID_SDK_ROOT/tools/bin
# adb, logcat
export PATH=${PATH}:$ANDROID_SDK_ROOT/platform-tools
# emulator
export PATH=${PATH}:$ANDROID_SDK_ROOT/emulator
~/.profile に追加後、念のため再起動後に再実行すると
$ ionic cordova prepare android
? Platform android is not installed! Would you like to install it? Yes
> cordova platform add android --save
{ Error: npm: Command failed with exit code 1 Error output:
npm ERR! code ENOLOCAL
npm ERR! Could not install from "android" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/kiya/.npm/_logs/2019-04-09T05_06_37_182Z-debug.log
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-common/src/superspawn.js:125:23)
at ChildProcess.emit (events.js:189:13)
at maybeClose (internal/child_process.js:970:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
stderr:
'npm ERR! code ENOLOCAL\nnpm ERR! Could not install from "android" as it does not contain a package.json file.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /home/kiya/.npm/_logs/2019-04-09T05_06_37_182Z-debug.log\n',
code: 1 }
[ERROR] An error occurred while running subprocess cordova.
cordova platform add android --save exited with exit code 1.
Re-running this command with the --verbose flag may provide more
information.
? Platform android is not installed! Would you like to install it? Yes
> cordova platform add android --save
{ Error: npm: Command failed with exit code 1 Error output:
npm ERR! code ENOLOCAL
npm ERR! Could not install from "android" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/kiya/.npm/_logs/2019-04-09T05_06_37_182Z-debug.log
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-common/src/superspawn.js:125:23)
at ChildProcess.emit (events.js:189:13)
at maybeClose (internal/child_process.js:970:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
stderr:
'npm ERR! code ENOLOCAL\nnpm ERR! Could not install from "android" as it does not contain a package.json file.\n\nnpm ERR! A complete log of this run can be found in:\nnpm ERR! /home/kiya/.npm/_logs/2019-04-09T05_06_37_182Z-debug.log\n',
code: 1 }
[ERROR] An error occurred while running subprocess cordova.
cordova platform add android --save exited with exit code 1.
Re-running this command with the --verbose flag may provide more
information.
あれれ?同じエラーが…
"Could not install from "android" as it does not contain a package.json file."をぐぐってみると iOS で同じ現象に出会ったという人が!その人は ios/ というディレクトリを削除したらエラーが出なくなったとのこと。早速 android/ ディレクトリを削除して再実行すると正常に追加できました\(^_^)/
0 件のコメント:
コメントを投稿