ionic-cli: [3.6] events.js:182 throw er; // Unhandled ‘error’ event

Soimething seems to have gone wrong with CLI 3.6 on Windows:

https://forum.ionicframework.com/t/error-like-shown-below-when-running-ionic-serve-command-in-cmd-prompt/99944 https://forum.ionicframework.com/t/ionic-cli-error-after-update/99986

D:\MyCloud\git\cow-v2>ionic info --verbose
[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: 'D:\\MyCloud\\git\\cow-v2', local: true, binPath:
        'C:\\Users\\Adrian\\AppData\\Roaming\\npm\\node_modules\\ionic\\bin\\ionic', libPath:
        'D:\\MyCloud\\git\\cow-v2\\node_modules\\ionic\\dist\\index.js' }
[DEBUG] Loading local plugin @ionic/cli-plugin-proxy
[DEBUG] Throwing PLUGIN_NOT_INSTALLED for local @ionic/cli-plugin-proxy
[DEBUG] Loading local plugin @ionic/cli-plugin-ionic-angular
[DEBUG] Getting plugin info for ionic
[DEBUG] Checking for latest plugin version of ionic@latest.
[DEBUG] Getting plugin info for @ionic/cli-plugin-ionic-angular
[DEBUG] Checking for latest plugin version of @ionic/cli-plugin-ionic-angular@latest.
[DEBUG] New daemon pid: 39216

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: spawn C:\Program Files\nodejs\node.exe ENOENT
    at notFoundError (D:\MyCloud\git\cow-v2\node_modules\cross-spawn\lib\enoent.js:11:11)
    at verifyENOENT (D:\MyCloud\git\cow-v2\node_modules\cross-spawn\lib\enoent.js:46:16)
    at ChildProcess.cp.emit (D:\MyCloud\git\cow-v2\node_modules\cross-spawn\lib\enoent.js:33:19)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)

https://forum.ionicframework.com/t/error-after-update-to-ionic-3-6/99967

[WARN] You are not in an Ionic project directory. Project context may be missing.

cli packages:

    @ionic/cli-utils  : 1.6.0 (C:\Users\HP\AppData\Roaming\npm\node_modules\ionic\node_modules\@ionic\cli-utils)
    ionic (Ionic CLI) : 3.6.0 (C:\Users\HP\AppData\Roaming\npm\node_modules\ionic)

System:

    Node : v8.1.2
    OS   : Windows 10
    npm  : 5.0.3

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 21 (13 by maintainers)

Most upvoted comments

npm i -D -E ws@3.3.2

This solution works for me

Try to install @ionic/cli-utils, this fixed the issue for me. npm install @ionic/cli-utils

I think I found the cause:

  1. ionic daemon passes process.argv[0] to cross-spawn with shell: true . process.argv[0] contains node’s full path which contains spaces (C:\Program Files\nodejs\node.exe) .
  2. When cross-spawn is called with shell: true on node 6+, it passes the arguments directly to child_process.spawn without escaping the spaces in the command.
  3. child_process.spawn does not escape the spaces in the command name when passed to cmd.exe because it would break other things: nodejs/node#7367
  4. cmd.exe tries to execute 'C:\Program` and fails.

Removing the shell argument fixes it for me. It was added in this commit calling it better windows behavior.

@dwieeb : can you explain what did that fix? And could it be reverted?

Alternatively, should cross-spawn be changed to escape the command even if node supports shell: true natively?