Run/Build always "fails" with "exit code 1" even on success

Basically every time I run ionic cordova run/build ios/android, I get

[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova run ios (exit code 1).

But the command completes just fine and the app works as it should on the device. Any clues? D: It’s slightly misleading haha

global packages:

    @ionic/cli-utils : 1.0.0
    Cordova CLI      : 7.0.1
    Ionic CLI        : 3.0.0

local packages:

    @ionic/app-scripts              : 1.3.7
    @ionic/cli-plugin-cordova       : 1.0.0
    @ionic/cli-plugin-ionic-angular : 1.0.0
    Ionic Framework                 : ionic-angular 3.2.1

System:

    Node       : v6.10.0
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.2 Build version 8E2002
    ios-deploy : 1.9.0
    ios-sim    : 5.0.12

Run the same command with --verbose, maybe there is more output.
Run the same command without ionic in front, maybe also with --verbose, to maybe get more output.

Running ionic cordova build ios --verbose gives me this right off the bat and quits

[DEBUG] Checking for latest plugin version of ionic@latest.
"3.0.0"

[DEBUG] Latest version of ionic@latest is .
[DEBUG] !!! ERROR ENCOUNTERED !!!
SyntaxError: Unexpected end of JSON input
[DEBUG] SyntaxError: Unexpected end of JSON input
            at Object.parse (native)
            at /usr/local/lib/node_modules/ionic/node_modules/@ionic/cli-utils/dist/lib/plugins.js:212:36
            at next (native)
            at fulfilled (/usr/local/lib/node_modules/ionic/node_modules/@ionic/cli-utils/dist/lib/plugins.js:4:58)

Without ionic it completes just fine, same goes for without --verbose.

Ok, this one I have seen a few times.

Normally it is caused by missing CLI Plugins… but you seem to have them installed. Sometimes it is an invalid ionic.config.json file, discussed here: https://github.com/driftyco/ionic-cli/issues/2275

Can you try the current alpha of the next CLI version? npm i -g ionic@canary to install. Then we know if this will be solved better with CLI 3.1.

That worked, but it still fails after the build has succeeded

** BUILD SUCCEEDED **


[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.

[DEBUG] !!! ERROR ENCOUNTERED !!!
[ERROR] An error occurred while running cordova build ios (exit code 1).

I suppose I’ll just live with it, if you don’t have a clue haha

again please, this should give more helpful output now.

That’s what I did, I’ll paste majority of the output:

[DEBUG] Load global plugin @ionic/cli-plugin-proxy
[DEBUG] Throwing PLUGIN_NOT_INSTALLED for @ionic/cli-plugin-proxy
[DEBUG] Load local plugin @ionic/cli-plugin-cordova from /Users/Michael/Workspaces/brokerApp/node_modules/@ionic/cli-plugin-cordova
[DEBUG] Load local plugin @ionic/cli-plugin-ionic-angular from /Users/Michael/Workspaces/brokerApp/node_modules/@ionic/cli-plugin-ionic-angular
Running app-scripts build: --iscordovaserve --externalIpRequired --nobrowser

[10:27:22]  build dev started ...
[10:27:22]  clean started ...
[10:27:22]  clean finished in 2 ms
[10:27:22]  copy started ...
[10:27:22]  transpile started ...
[10:27:26]  transpile finished in 4.58 s
[10:27:26]  preprocess started ...
[10:27:26]  deeplinks started ...
[10:27:26]  deeplinks finished in 172 ms
[10:27:26]  preprocess finished in 173 ms
[10:27:26]  webpack started ...
[10:27:27]  copy finished in 4.94 s
[10:27:42]  webpack finished in 16.02 s
[10:27:42]  sass started ...
[10:27:44]  sass finished in 1.71 s
[10:27:44]  postprocess started ...
[10:27:44]  postprocess finished in 12 ms
[10:27:44]  lint started ...
[10:27:44]  build dev finished in 22.55 s
> cordova build ios

--- snip, no errors but I can paste all of it if you want, seems irrelevant since it happens for android too :) ---

** BUILD SUCCEEDED **


[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.

[DEBUG] !!! ERROR ENCOUNTERED !!!
[ERROR] An error occurred while running cordova build ios (exit code 1).

[DEBUG] Throwing PLUGIN_NOT_INSTALLED for @ionic/cli-plugin-proxy

Could this be it?

Yep, try this:

npm install --save-dev --save-exact @ionic/cli-plugin-proxy@latest

This seems kinda contradicting…

[DEBUG] Throwing PLUGIN_NOT_INSTALLED for @ionic/cli-plugin-proxy
[DEBUG] Load local plugin @ionic/cli-plugin-proxy from /Users/Mic...

Still completes with exit code 1, but now it only does so with --verbose! So that’s progress :smiley:

There is still something broken deep down…

Could you create a ticket at https://github.com/driftyco/ionic-cli/issues please? Someone from CLI should look at it, probably more people will turn up with problems like this when CLI v3 gets more and more installs. Include a link to this thread and all the relevant output you already posted here (and maybe the package.json). Thanks.

1 Like

Was in the middle of doing it, then realized I suck at reading. When it throws “PLUGIN_NOT_INSTALLED”, it was apparently for the global install of @ionic/cli-plugin-proxy.

[DEBUG] Load global plugin @ionic/cli-plugin-proxy
[DEBUG] Throwing PLUGIN_NOT_INSTALLED for @ionic/cli-plugin-proxy
[DEBUG] Load local plugin @ionic/cli-plugin-proxy from /Users/Mic...

I ran

npm install @ionic/cli-plugin-proxy -g

and it went away, though it still exited with code 1. I assumed it wasn’t really necessary to have it globally, and that this was unrelated to the exit code thing. So I decided to remove my platforms and plugins and re-install it all, and now the exit code thing has gone away. So the CLI wasn’t to blame for that after all, but now I have no idea what caused it…

Sorry for what seems like a waste of time D:

1 Like

That’s the frustrating thing with these Ionic CLI v3 problems popping up right now: They are there and then they aren’t. Right now I can’t distinguish the real ones by the ones fixed by just reinstalling :confused:

2 Likes

3 posts were split to a new topic: Error: Cannot read property ‘replace’ of undefined