Ionic serve fails after upgrade to CLI 5.0.2 - [ng] The system cannot find the path specified

I upgraded the ionic CLI to 5.0.2 (from 4.12.something, if I remember correctly) with

npm install -g ionic

after that, ionic serve no longer works:

C:\mobile\myappdir>ionic serve
> ng.bat run app:serve --host=localhost --port=8100
[ng] The system cannot find the path specified.

[ERROR] ng has unexpectedly closed (exit code 1).

        The Ionic CLI will exit. Please check any output above for error details.

I tried running the following, but it didn’t change anything:

npm install -g cordova-res native-run
npm install @ionic/angular-toolkit@latest

Other pertinent info:


C:\mobile\myappdir>ionic info

Ionic:

Ionic CLI : 5.0.2 (C:\Users\alfon1\AppData\Roaming\nvm\v10.15.0\node_modules\ionic)
Ionic Framework : @ionic/angular 4.4.0
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.3.9
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.5.1

Cordova:

Cordova CLI : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 7.1.4
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.4.1, (and 8 other plugins)

Utility:

cordova-res : 0.3.0
native-run : 0.2.5

System:

Android SDK Tools : 26.0.2 (c:\users\alfon1\appdata\local\android\sdk)
NodeJS : v10.15.0 (C:\Program Files\nodejs\node.exe)
npm : 6.4.1
OS : Windows 10


Everything was running correctly until the CLI upgrade.

Other ionic commands also fail with a similar message (e.g. ionic build).

“Cordova build android” runs without an issue and produces an APK.

“ionic cordova build android” fails:

C:\mobile\davdtexv03>ionic cordova build android
> ng.bat run app:ionic-cordova-build --platform=android
The system cannot find the path specified.
[ERROR] An error occurred while running subprocess ng.

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

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

C:\mobile\davdtexv03>

I spent a couple hours tryng to solve the same problem as you.
And, unfortunately, the only solution I found is

npm i -g ionic@4.12.0

I’ll just wait for other to help us, but until that, with the old CLI I can keep working…

1 Like

Dear Bruno,

Thanks for your message.

After spending some more time without any tangible results, I had to do the same.

For the record, some of the things I tried before reverting to 4.12.0:

npm install -g cordova-res native-run
npm install @ionic/angular-toolkit@latest
npm update -g cordova
cordova platform update

All this didn’t help. Then I reverted to the old version of ionic-cli (npm i -g ionic@4.12.0) and everything was fine. Just to be sure, I moved to the new version again (npm i -g ionic) and again ionic serve did not work. I then tried npm install to check for missing dependencies and npm audit to check for other issues. Both commands found no issues. At last I reverted to 4.12.0 once again.

On the plus side, I have found that I can move between the two versions with reproducible results, so if someone here asks me to check something or offers a fix (or at least a workaround), I can do it.

2 Likes

I tried installing ionic CLI 5.1.0, but it has the same problems as 5.0.2, so I went back to 4.12.0 which works.

Can you try remove and add platform again?

I tried it but it didn’t solve the issue:

C:\mobile\davdtexv03>ionic cordova platform rm android

cordova.cmd platform remove android
Removing platform android from config.xml file…
Removing android from cordova.platforms array in package.json

C:\mobile\davdtexv03>ionic cordova platform add android

cordova.cmd platform add android
Using cordova-fetch for cordova-android@^8.0.0
Adding android project…
Creating Cordova project for the Android platform:
Path: platforms\android
Package: gr.synpan.www.dav.d_tex
Name: D_tex
Activity: MainActivity
Android target: android-28
Subproject Path: CordovaLib
Subproject Path: app
Android project created with cordova-android@8.0.0
Installing “cordova-plugin-app-version” for android
Installing “cordova-plugin-contacts” for android
Installing “cordova-plugin-device” for android
Installing “cordova-plugin-inappbrowser” for android
Installing “cordova-plugin-ionic-keyboard” for android
Installing “cordova-plugin-ionic-webview” for android
Subproject Path: CordovaLib
Subproject Path: app
Installing “cordova-plugin-network-information” for android
Installing “cordova-plugin-splashscreen” for android
Installing “cordova-plugin-statusbar” for android
Installing “cordova-plugin-whitelist” for android

           This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.

Installing “cordova-sqlite-storage” for android
installing external dependencies via npm
for package name: cordova-sqlite-storage
npm install of external dependencies ok

ionic cordova resources android --force
cordova-res.cmd android
[cordova-res] Generated 18 resources for android
[cordova-res] Wrote to config.xml

C:\mobile\davdtexv03>ionic serve --lab

ng.bat run app:serve --host=localhost --port=8100
[ng] The system cannot find the path specified.

[ERROR] ng has unexpectedly closed (exit code 1).

    The Ionic CLI will exit. Please check any output above for error details.