Cli gone after any ionic command

Hi,

I’ve a strange problem. If I use any cli command, the folder node_modules/ionic is empty after and the next command fails.

Anyone with the same behavior?

What is your ionic info?
How do you fix the issue?
Run a command with --verbose and post the output here if it “deleted” the folder again.

Is there anything unusual about the filesystem involved here (such as it being inside a VM)?

No vm involved, plain MacOS. An yarn upgrade will fix it temporarly

cli packages:

@ionic/cli-plugin-cordova       : 1.6.2
@ionic/cli-plugin-ionic-angular : 1.4.1
@ionic/cli-utils                : 1.7.0
ionic (Ionic CLI)               : 3.7.0

global packages:

Cordova CLI : 7.0.1 

local packages:

@ionic/app-scripts : 2.1.3
Cordova Platforms  : ios 4.4.0
Ionic Framework    : ionic-angular 3.6.0

System:

Node       : v8.2.1
OS         : macOS Sierra
Xcode      : Xcode 8.3.3 Build version 8E3004b 
ios-deploy : 1.9.1 
npm        : 5.3.0

[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: ‘/Users/dominik/Projects/testapp’, local: true, binPath:
‘/usr/local/lib/node_modules/ionic/bin/ionic’, libPath:
‘/Users/dominik/Projects/testapp/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-cordova
[DEBUG] Loading local plugin @ionic/cli-plugin-ionic-angular
[DEBUG] Daemon found (pid: 2114)
[DEBUG] Getting plugin info for ionic
[DEBUG] Checking for latest plugin version of ionic@latest.
[DEBUG] Getting plugin info for @ionic/cli-plugin-cordova
[DEBUG] Checking for latest plugin version of @ionic/cli-plugin-cordova@latest.
[DEBUG] Getting plugin info for @ionic/cli-plugin-ionic-angular
[DEBUG] Checking for latest plugin version of @ionic/cli-plugin-ionic-angular@latest.

cordova platform add android --save
:heavy_multiplication_x: Running command - failed!

[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova platform add android --save (exit code 1):

    Using cordova-fetch for cordova-android@~6.2.2
    Adding ionic-plugin-keyboard project...
    Error: Your ionic-plugin-keyboard platform does not have Api.js

➜ testapp git:(master) ✗ ionic cordova platform add android --verbose
{ Error: Cannot find module ‘/Users/dominik/Projects/testapp/node_modules/ionic’
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at /usr/local/lib/node_modules/ionic/bin/ionic:18:13
at code: ‘MODULE_NOT_FOUND’ }

Update:
Seems like it’s an roblem with the yarn integration. In a short test with deactivated yarn and just npm ist seems to work

Oh, that would be worth an issue at the ionic-cli repo then. IT definitely shouldn’t delete the local Ionic CLI no matter what. But the local CLI is quite new, maybe nobody tested with yarn yet.


Normally that shouldn’t happen as well, seems like the ionic-plugin-keyboard wasn’t installed properly as well.

Can you ionic start blank blank a new project and try there as well? Does the same thing happen?

It was an empty projekt, just generated the sidemenu starter an minute before.

Strange, then the creation of the project already failed by not correctly downloading/installing that plugin. Could point to deeper problems, but could also be caused by using yarn of course.

Maybe the failure and the eletion are different problems. The deletion could be caused by the usage of yarn and the cordova error could point to another problem

Could be. But both are connected to the “getting and saving packages to node_modules” step (cordova plugins are also downloaded there before being copied over).

Try if using npm fixes things completely - and make sure to create that issue on Github about the yarn problems.

Same error here (I had a similar problem last week and moving from node8 to node6 fixed it. still on node6 and its broken again).

(also using nvm as seen below)

install clean ionic-cli

project-ventoux $ npm i -g ionic
/Users/santekotturi/.nvm/versions/node/v6.11.1/bin/ionic -> /Users/santekotturi/.nvm/versions/node/v6.11.1/lib/node_modules/ionic/bin/ionic
/Users/santekotturi/.nvm/versions/node/v6.11.1/lib
└─┬ ionic@3.9.2
  └─┬ @ionic/cli-utils@1.9.2
    ├─┬ @types/gulp@3.8.33
    │ └── @types/vinyl@2.0.1
    └─┬ inquirer@3.2.2
      └── cli-width@2.2.0

run v1 app:

project-ventoux $ ionic serve
{ Error: Cannot find module '/Users/santekotturi/Developer/poco/project-ventoux/node_modules/ionic'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at /Users/santekotturi/.nvm/versions/node/v6.11.1/lib/node_modules/ionic/bin/ionic:18:13 code: 'MODULE_NOT_FOUND' }

cant even run ionic info to print out versions… :disappointed_relieved:

Try running npm i ionic inside the project folder. It looks like the CLI is looking for locally installed friends that aren’t there.