Project definition could not be found

#1

I’m unable to run ionic cordova build android due to the following error:

> ng run app:ionic-cordova-build --platform=android
The run command requires to be run in an Angular project, but a project definition could not be found.
[ERROR] An error occurred while running subprocess ng.

        ng run app:ionic-cordova-build --platform=android exited with exit code

        1.

        Re-running this command with the --verbose flag may provide more
        information.

This is the output from running it with --verbose:

  ionic:lib Terminal info: { tty: true, ci: false, windows: true } +0ms
  ionic:lib CLI global options: { _: [ 'cordova', 'build', 'android' ], help: null, h: null, verbose: true, quiet: null, interactive: true, color: true, confirm: null, json: null, project: null, '--': [] } +6ms
  ionic:lib:project Project type from config: @ionic/angular (angular) +0ms
  ionic:lib:project Project details: { configPath: 'c:\\Projects\\drbapp\\ionic.config.json', errors: [], context: 'app', type: 'angular' } +1ms
  ionic Context: { binPath: 'C:\\Users\\stefk\\AppData\\Roaming\\npm\\node_modules\\ionic\\bin\\ionic', libPath: 'C:\\Users\\stefk\\AppData\\Roaming\\npm\\node_modules\\ionic', execPath: 'c:\\Projects\\drbapp', version: '4.9.0' } +0ms
  ionic:lib:integrations:cordova:config Using config.xml: c:\Projects\drbapp\config.xml +0ms
  ionic:lib:telemetry Sending telemetry for command: 'ionic cordova build' [ 'android', '--verbose', '--interactive', '--color' ] +0ms
  ionic:lib:hooks Looking for ionic:build:before npm script. +0ms
  ionic:lib:build Looking for ionic:build npm script. +0ms
> ng run app:ionic-cordova-build --platform=android
The run command requires to be run in an Angular project, but a project definition could not be found.
[ERROR] An error occurred while running subprocess ng.

        ng run app:ionic-cordova-build --platform=android exited with exit code

        1.

        Re-running this command with the --verbose flag may provide more
        information.
  ionic:cli-framework:utils:process onBeforeExit handler: process.exit received+0ms
  ionic:cli-framework:utils:process onBeforeExit handler: running 1 functions +1ms
  ionic:cli-framework:utils:process error while killing process tree for 17852:{ Error: Command failed: taskkill /pid 17852 /T /F
  ionic:cli-framework:utils:process ERROR: The process "17852" not found.
  ionic:cli-framework:utils:process
  ionic:cli-framework:utils:process     at ChildProcess.exithandler (child_process.js:297:12)
  ionic:cli-framework:utils:process     at ChildProcess.emit (events.js:197:13)
  ionic:cli-framework:utils:process     at maybeClose (internal/child_process.js:978:16)
  ionic:cli-framework:utils:process     at Socket.stream.socket.on (internal/child_process.js:395:11)
  ionic:cli-framework:utils:process     at Socket.emit (events.js:197:13)
  ionic:cli-framework:utils:process     at Pipe._handle.close (net.js:611:12)
  ionic:cli-framework:utils:process   killed: false,
  ionic:cli-framework:utils:process   code: 128,
  ionic:cli-framework:utils:process   signal: null,
  ionic:cli-framework:utils:process   cmd: 'taskkill /pid 17852 /T /F' } +216ms
  ionic:cli-framework:utils:process onBeforeExit handler: error from function: { Error: Command failed: taskkill /pid 17852 /T /F
  ionic:cli-framework:utils:process ERROR: The process "17852" not found.
  ionic:cli-framework:utils:process
  ionic:cli-framework:utils:process     at ChildProcess.exithandler (child_process.js:297:12)
  ionic:cli-framework:utils:process     at ChildProcess.emit (events.js:197:13)
  ionic:cli-framework:utils:process     at maybeClose (internal/child_process.js:978:16)
  ionic:cli-framework:utils:process     at Socket.stream.socket.on (internal/child_process.js:395:11)
  ionic:cli-framework:utils:process     at Socket.emit (events.js:197:13)
  ionic:cli-framework:utils:process     at Pipe._handle.close (net.js:611:12)
  ionic:cli-framework:utils:process   killed: false,
  ionic:cli-framework:utils:process   code: 128,
  ionic:cli-framework:utils:process   signal: null,
  ionic:cli-framework:utils:process   cmd: 'taskkill /pid 17852 /T /F' } +6ms
  ionic:cli-framework:utils:process onBeforeExit handler: exiting (exit code 1)+5ms

Here is my output for ionic info:

[ERROR] Error loading @ionic/angular package.json: Error: Cannot find module
        '@ionic/angular/package'
[ERROR] Error loading @ionic/angular-toolkit package.json: Error: Cannot find
        module '@ionic/angular-toolkit/package'
[ERROR] Error loading @angular-devkit/build-angular package.json: Error: Cannot

        find module '@angular-devkit/build-angular/package'

Ionic:

   ionic (Ionic CLI)             : 4.9.0 (C:\Users\stefk\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : not installed
   @angular-devkit/build-angular : not installed
   @angular-devkit/schematics    : 7.2.3
   @angular/cli                  : 7.2.3
   @ionic/angular-toolkit        : not installed

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.1.4
   Cordova Plugins       : no whitelisted plugins (22 plugins total)

System:

 (C:\Users\stefk\AppData\Local\Android\android-sdk)
   NodeJS            : v11.8.0 (C:\Program Files\nodejs\node.exe)
   npm               : 6.7.0
   OS                : Windows 7

This is after upgrading to the latest node.js, npm, ionic CLI, and cordova, in an attempt to fix android builds failing due to “Unable to merge dex” (and unlike what the countless search results for this error suggest, cordova clean android did nothing to fix it), but this is a legacy Ionic v1 app for which a rewrite for the latest Ionic is not feasible for at the moment.

I see there are plenty of problems I have now from this upgrade, but I’m unsure how to fix any of them.

I tried running ng update @angular/cli --migrate-only --from=1.4.3 (I’m assuming 1.4.3 is the version number I was supposed to put there, it’s the version number indicated in www/lib/ionic/js/angular/angular.js), but that only gives me an error stating Could not find configuration file.

1 Like
#2

FYI, this issue may be related to this undetermined issue with ionic-cli.