IONIC : A utility CLI has unexpectedly closed

137.8k Views Asked by At

I got this error when i run ionic serve The Ionic CLI will exit. Please check any output above for error details.

my ionic info

$ionic info
Ionic:

   ionic (Ionic CLI)  : 4.0.1 (C:\Users\Pc\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.8

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.0.0

System:

   Android SDK Tools : 25.3.1
   NodeJS            : v6.10.1 (C:\Program Files\nodejs\node.exe)
   npm               : 5.3.0
   OS                : Windows 10

Environment:

   ANDROID_HOME : C:\Users\Pc\AppData\Local\Android\sdk
12

There are 12 best solutions below

0
Rakesh Mishra On BEST ANSWER

Run the below command, being in root directory of Ionic project:

npm install @ionic/app-scripts@latest --save-dev

Then you can try Ionic serve or Ionic s.

0
Abdennaji Firas On

Try running:

npm install @ionic/lab
2
Vagner Sabadi On

You must kill the NodeJs service I believe it's a bug

0
ChamathPali On

Try replacing the package.json scripts parts. Worked for me.

  "scripts": {
    "build": "ionic build",
    "serve": "ionic build",
    "start": "npm run serve"
  },
0
Nourdine Alouane On

I had a similar issue:

Assertion `args[1]->IsString()' failed.

A utility CLI has unexpectedly closed

I fixed that by installing natives lib through npm:

npm i natives
0
Jack M On

I had a similar issue. I tried several different solutions, and for some reason different ones worked on different machines. Because I'm an illogical masochist, I attempted to fix this issue in the same project on 3 different laptops instead of sending the new fixed version to the other laptops.

The best answer I came up with is to:

  • Delete node_modules
  • copy node_modules from a different project (I used an earlier version of my app)
  • run npm i to install any missing modules

I think this approach should work for almost all instances.

0
N.Balgopal Patro On

Simpy run

npm install @ionic/app-scripts@latest --save-dev

and then

ionic serve

This error is because of some audit during installing a plugin or adding a plug in

0
Rahul Sharma On

Maybe there is an issue in your hosts file. Make sure your ::1 should enable or not commented.

Example:

enter image description here

0
basilisk On

I don't know why but using sudo was the only way to solve this on my ubuntu machine! I just needed to run the command using sudo:

sudo ionic serve
0
nativelectronic On

if you get this in the log:

The target entry-point "@ionic-native/media-capture" has missing dependencies:

  • @ionic-native/core

try this,

npm install --save @ionic-native/core
0
Cedric Ipkiss On

My solution: Upgrade Angular. It'll reveal the real reason for unexpectedly closing in a more verbouse error message. Mine was incompatible dependencies. I simply edited package.json with the right depencies, and ran npm update

0
B4ldur On

For any Linux Users: This error might occur if you installed node.js via the snapstore. Either change PATH to /usr/local/bin/node or use npm to update/install node.js again at the right place.