I cant build Blank Starter with --prod --release

After upgrading my app to ionic 6, I could nolonger build it with --prod --release, but the debug version could build. I get this error when I run -

ionic cordova build browser --prod --release

ERROR:

    An unhandled exception occurred: Project target does not exist.
    See "/private/var/folders/4w/rxgf0q7j7qj5hmk2ncvnm5140000gp/T/ng-KU4iG3/angular-errors.log" for further details.
    [ERROR] An error occurred while running subprocess ng.
    
    ng run app:ionic-cordova-build:production --platform=browser exited with
    exit code 127.
    
    Re-running this command with the --verbose flag may provide more
    information.

The log referenced above has this data:

  [error] Error: Project target does not exist.
      at findProjectTarget (/Volumes/Projects/business/cryptoy/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js:49:15)
      at Object.getBuilderName (/Volumes/Projects/business/cryptoy/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js:62:46)
      at WorkspaceNodeModulesArchitectHost.getBuilderNameForTarget (/Volumes/Projects/business/cryptoy/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js:101:35)
      at RunCommand.runSingleTarget (/Volumes/Projects/business/cryptoy/node_modules/@angular/cli/models/architect-command.js:242:55)
      at RunCommand.runArchitectTarget (/Volumes/Projects/business/cryptoy/node_modules/@angular/cli/models/architect-command.js:295:35)
      at RunCommand.run (/Volumes/Projects/business/cryptoy/node_modules/@angular/cli/commands/run-impl.js:15:25)
      at RunCommand.validateAndRun (/Volumes/Projects/business/cryptoy/node_modules/@angular/cli/models/command.js:136:33)
      at async runCommand (/Volumes/Projects/business/cryptoy/node_modules/@angular/cli/models/command-runner.js:224:24)
      at async default_1 (/Volumes/Projects/business/cryptoy/node_modules/@angular/cli/lib/cli/index.js:70:31)

So to make sure the issue was with my code, I installed a new blank app with ionic start newapp blank, and executed a build with —prod and I got the same exact error.

Here is my ionic info:

Ionic:

   Ionic CLI                     : 5.4.16 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 6.0.13
   @angular-devkit/build-angular : 13.2.6
   @angular-devkit/schematics    : 13.2.6
   @angular/cli                  : 13.2.6
   @ionic/angular-toolkit        : 6.1.0

Cordova:

   Cordova CLI       : 11.0.0
   Cordova Platforms : browser 6.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 3 other plugins)

Utility:

   cordova-res : 0.15.4
   native-run  : not installed

System:

   NodeJS : v14.15.5 (/usr/local/bin/node)
   npm    : 6.14.11
   OS     : macOS Mojave

I appreciate your time and help, thank you!
Philip.

Hi

What does ionic build —prod do for you? (Skipping cordova)

Or skipping the —release flag or even both?

Any errors with those options?

Ok, ionic build --prod worked. It built the application, I see a success message. Do I still have access to cordova plugins?

Nope

Ionic build only generates web assets. You need to add cordova keyword

But…

The other issue I see is that your cordova command says you want to build for browser

Why is that? While it is an option, it is not a common one as not many plugins feauture broswer code. Mostly android and iOS. Is there some sort of plugin you need that uses broswer (and cannot be resolved via rwgular web api - which imho is imposible)

For which target are you building?

I am building a web app, or more like a website, accessible exclusively through the browser. I’ve been careful to include only plugins that are compatible with the browser.

This worked fine in ionic 3, I would build a browser platform then upload the www folder in the browser directory of the platforms folder, and served that to a domain URL. It all worked fine. I’m having issues doing the same for ionic 5, I upgraded the project to ionic 5, and I need to serve it as a website. Kindly advice,

Thank you.

Ok nice

Did you add browser as platform? Ionic platform add browser?

Maybe it is not within your appetite but if the target is only web, then you dont need cordova. Web apis will work just fine. And I for other stuff there are great packages available.

Which plugins u want to use?

. If u start a new project, consider skipping cordova. Reduce complexity and depencies. Next a web api approach will give u way more community and official docs ad well as more apis - I bet there are more web apis/packages than relevant cordova browser plugins!

Then ionic build —prod will do and then everything u need to upload will be in the www folder after the build

Ok I didn’t know much about web APIs, are there good alternatives for these below:

      "cordova-plugin-nativestorage": {},
      "cordova-plugin-geolocation": {
        "GEOLOCATION_USAGE_DESCRIPTION": "To locate Care Facilities"
      },
      "cordova-plugin-camera": {
        "ANDROID_SUPPORT_V4_VERSION": "27.+",
        "CAMERA_USAGE_DESCRIPTION": "Use Camera",
        "PHOTOLIBRARY_USAGE_DESCRIPTION": "User Photo Library"
      },
      "cordova-plugin-file": {},
      "phonegap-plugin-mobile-accessibility": {},
      "cordova-plugin-stripe": {},
      "cordova-plugin-file-opener2": {
        "ANDROID_SUPPORT_V4_VERSION": "27.+"
      }

Those are the most used plugins in our app. Thank you again!

Please advice, would it be as easy to build an app out of this same code when I exclude Cordova? Because we have plans in the near future to launch Android and iOS versions of this same code. Thank you!

If that is what u want then maybe cordova is a better option

Even though some of the web apis may even work when part of an ios or android bundle

Consider using capacitorjs as alternative to cordova and do a small test app to see how it works. Also getting used to a bit different developer flow

Capacitor you can regard as replacing cordova - another nice product from ionic team

And from the face of it, it has these plugins as well

It should be easy to build a technical test app to see if the web apis also do the trick as part of an android or ios bundle

Thank you!! Unfortunately, Geofencing is not possible with only Web Apis, and we rely on it for our GPS tracking feature of the application.

Do you have any idea how to go about the original error “An unhandled exception occurred: Project target does not exist.” because I can’t build with:

ionic cordova build browser --prod --release

Like it was with ionic 3. I tried to execute that on my project, and it failed on all, I also installed a blank starter template, and tried to build with the code above, with no changes to code whatsoever, I got the same error, which was odd, given the starter is pure intouched code from iONIC.

I really appreciate your support and advice,

Thank you again!

Geofencing or geolocation?

Two different things

Both, we track staff location, and trigger some events when they enter specific pre-defined locations so geofencing is also used and required.

Ok
I have no specific guidance on the error. Havent worked with browser platform in a while

did you add the browser as platform?

Which I reckon you did but u never confirmed you followed that step (ionic cordova platform add browser)

Ps. I dont see a browser implementarion in the geofencing plugin source

U using this one? cordova-plugin-geofence/src at master · cowbell/cordova-plugin-geofence · GitHub

Again, maybe capacitorjs is a way to go for future projects?

Sorry I didn’t confirm, but yes, I added the platform. Removed it and re-added it just to be sure, but the error persisted. I’ll give a try for capacitor (never worked with it before), and I’m afraid to make drastic changes, our app is over 200 pages, and is used by so many users we just can’t deal with abrupt bugs, let I’ll try that out.

Does this imply ionic officially nolonger works with cordova, past ionic 3? because no project on our end can built with ionic cordova build --prod command, all projects fail.

Thank you.

It should work with ionic 4 5 6

So sorry to say - but there are bugs bothering you :grinning::grinning::grinning::grinning:

Cant try myself now - maybe I find a moment tomorrow. Just out of curiosity

Haha, yeah bugs!

Ok please, I’ll be delighted to hear your feedback from your tests. I’ll start look up capacitor alternatives to the cordova plugins I have, hopefully it’ll all align up.

I’ll update this thread if any issues,

Thank you again for your time and support!
Philip.

1 Like

Ok cool
If u have sample barebone project to share please do so (github)
Keep u posted

1 Like

@wakadala - dude!

Did you Google the error at all? :slight_smile:

I managed to reproduce the error you easily - and this fixed it

Google is a (web)developer’s best friend - and go-to place :wink:

And again:

1 Like

This specific command did it for me:

ng add @ionic/cordova-builders

Thank you!

1 Like