Ionic-cli: [CLI 3.6] Local CLI installation is mandatory, shouldn't

Created on 28 Jul 2017  路  10Comments  路  Source: ionic-team/ionic-cli

Description:

In the changeling of the version 3.6 of the CLI following is described:

Added recommendation for local CLI installation. You can use the global ionic binary from npm i -g ionic installation and it will use the local CLI version if installed, similar to gulp or other CLIs. The CLI is installed locally for new projects by default.

After having upgraded to CLI 3.6 and all my Ionic packages, except installing a local Ionic CLI, I could not start ionic serve my local server without having installed a local CLI first. Each time I start it following question gonna pop up:

WARN] No local CLI detected.
Starting with CLI 3.6, the CLI must be installed locally to use local CLI plugins.
? Install now?

If I answer No, the process just stop.

Of course I could install a local CLI to solve the issue and then the process gonna be ok, but as staten in the changelog, a local CLI should be optional.

Steps to Reproduce:

npm install -g ionic@latest
npm install @ionic/app-scripts@latest --save-dev
npm install ionic-angular@latest --save
ionic serve

Other Information:

Forum: https://forum.ionicframework.com/t/no-local-cli-detected-starting-with-cli-3-6-the-cli-must-be-installed-locally-to-use-local-cli-plugins/99912

Most helpful comment

So, a bit more explanation here is probably needed. The functionality of ionic serve comes from whichever project plugin is installed. There are two project plugins, one for Ionic 1 (@ionic/cli-plugin-ionic1) and Ionic Angular (@ionic/cli-plugin-ionic-angular). When ionic serve is run, a hook is run that the plugin picks up on. Without the plugins, the ionic serve command "fails" silently (which it shouldn't--there should be a message there, I made an issue: https://github.com/ionic-team/ionic-cli/issues/2571).

This is what I meant by "the CLI must be installed locally to use local CLI plugins". If you're running a binary from your global node_modules, it is bad practice to use require() in Node for local packages, which the CLI pre 3.6 was doing. Indeed, it brought about quite a few obscure issues with runtime JS errors due to incompatibilities with version mismatches between the CLI and the plugins (which really are too complicated to be plugins in the first place--I am working on fixing this). So now we basically say that the global CLI only loads global CLI plugins and the local CLI only loads local CLI plugins, which means packages are only ever really under a single node_modules directory, and versioned accordingly by npm.

You could _maybe_ try to install @ionic/cli-plugin-ionic-angular _globally_ if you only use Ionic Angular for your apps, but I wouldn't recommend it.

May I ask why you are responding No? A great deal of Ionic toolkit packages are installed as dev dependencies of your app already: @ionic/app-scripts, @ionic/cli-plugin-cordova, @ionic/cli-utils, @ionic/cli-plugin-ionic-angular...

All 10 comments

So, a bit more explanation here is probably needed. The functionality of ionic serve comes from whichever project plugin is installed. There are two project plugins, one for Ionic 1 (@ionic/cli-plugin-ionic1) and Ionic Angular (@ionic/cli-plugin-ionic-angular). When ionic serve is run, a hook is run that the plugin picks up on. Without the plugins, the ionic serve command "fails" silently (which it shouldn't--there should be a message there, I made an issue: https://github.com/ionic-team/ionic-cli/issues/2571).

This is what I meant by "the CLI must be installed locally to use local CLI plugins". If you're running a binary from your global node_modules, it is bad practice to use require() in Node for local packages, which the CLI pre 3.6 was doing. Indeed, it brought about quite a few obscure issues with runtime JS errors due to incompatibilities with version mismatches between the CLI and the plugins (which really are too complicated to be plugins in the first place--I am working on fixing this). So now we basically say that the global CLI only loads global CLI plugins and the local CLI only loads local CLI plugins, which means packages are only ever really under a single node_modules directory, and versioned accordingly by npm.

You could _maybe_ try to install @ionic/cli-plugin-ionic-angular _globally_ if you only use Ionic Angular for your apps, but I wouldn't recommend it.

May I ask why you are responding No? A great deal of Ionic toolkit packages are installed as dev dependencies of your app already: @ionic/app-scripts, @ionic/cli-plugin-cordova, @ionic/cli-utils, @ionic/cli-plugin-ionic-angular...

@dwieeb thx for your answer. I answer no because having a global Ionic-cli kind of "force" to always being up-to-date in all my Ionic project, which was until kind of the way I worked. Once I update the global one, I update all projects I need.

anyway then, if having a local CLI is finally kind of a must, then the changelog should be modified.

Added recommendation for local CLI installation. You can use the global ionic binary from npm i -g ionic installation and it will use the local CLI version if installed...

is not that clear. Maybe

Added recommendation for local CLI installation. From now on, a local CLI installation is needed to run binary from your local node_modules.

Would also maybe good to add a remark about in the last ionic-angular changelog, since the described upgrade display an upgrade to ionic-cli 3.6

thx for your answer. I answer no because having a global Ionic-cli kind of "force" to always being up-to-date in all my Ionic project, which was until kind of the way I worked. Once I update the global one, I update all projects I need.

The CLI still whines incessantly when things are out-of-date. It does this for global packages when the global CLI is used outside of project directories and it does this for local packages when the local CLI is used inside of project directories.

I am fixing up the changelog right now.

@dwieeb thx for the explanation, sounds good to me. also thx for the update of the changelog, really nice

@dwieeb I read it with my strong french accent and I totally got it this time ;)

thx for the changelog modifications

Thank you for working with me! 馃槃

When I install as below code than error occurred as below......

npm install --save-dev --save-exact ionic@latest
WARN - There was no CLI project plugin that responded to ionic serve.
Make sure you have the Ionic CLI and a suitable project plugin installed locally...

Please help me and solve it....

@bafinhusen That command should install the actual latest CLI, which is 3.9.0 and soon to be 3.9.1. If it does not, try npm cache verify.

Was this page helpful?
0 / 5 - 0 ratings