So I have this machine where I installed the new cli version 3.4.0 and started a project and everything is going smooth. I want also to work on another project that is created using 2.1.1
When I tried, it requested to install new dependencies and add it to the project. I don't want to do so because I am working with other developers who aren't willing to upgrade their cli to the latest version. I tried installing the cli locally using npm install [email protected] still ionic point to the global package.
How can I run the old project with the old cli if it exist in the package?
One way is to use nvm (or nvm-windows when you are on Windows) to have multiple node versions at the same time. Then you can install one CLI version on each node version and switch between them as you wish.
@janpio this seem like the only way available. I found on another issue that ionic-cli should be run globally and the team isn't intending to change that
https://github.com/ionic-team/ionic-cli/issues/388#issuecomment-97237198
So I guess that's the only way
The comment was 2015... so I think stuff could have changed since then ;)
But yeah, running locally is not super supported right now but I know the developers are looking into it. So if you want it, better create an issue that explains the expected functionality and usage and they will look into it.
Sure I will do. Will explain different use cases on why developers need that and the expected functionality. Thanks again
I'm also interested in a more convenient solution than installing a different ionic version globally whenever I have to switch from one to another project. Just to tell you about our use case: We're about 10 developers working on 10 different projects of customers (new ones, but also just maintenance of old ones), some of which are built on Ionic 1, some on Ionic 2, and the newest one on Ionic 3.
For the newer projects, we're partially using docker containing all required tools (Node, Cordova, Ionic etc) with the correct / project specific versions, which makes it easier. But still not perfect though, as iOS builds still need to be built directly on macOS.
Let me know if you're interested in details, or if you have some inputs!
Ionic supports this since the last or previous version. You just install a global version, but also a local version that also does the actual work. The local version is part of package.json and so is identical for all developers working on the same project.
Very cool, thanks @janpio ! Edit: I've installed version 2.1.18 locally in one project, and latest (3.9.2) in another project. But it doesn't seem to distinguish, it always takes the globally installed Ionic CLI, which only works for one project. Doing something wrong over here?
The old 2.1.18 didn't support this behavior, this of course only works with recent versions. But CLI 2.x is starting to break slowly anyway (You already can't start new projects with it...), there should be no real reason to keep this alive. CLI 3.x works with all versions of the framework.
I've the same need... @janpio CLI 3.x works with all versions if they were started with it. I've some projects started with CLI 2.x that breaks the 3.x scripts. I don't have time to debug what happens and make everything works until the next break. So, for those, I stuck with the 2.2.3 and I'm starting to save the exact Ionic version for every new project. Using nvm rapidly becames a not-so-good solution because Ionic evolves more rapidly than node so a project with 3.9.1 and 3.9.2 were installed on the same node 8.4.0. I know that it shouldn't break the compatibility but, as bad experiences taught me, I prefer to maintain the exact Ionic version.
I've opened a FR on nvm hoping to get over this soon.
@Takkuz We are in turbulent times in the node/javascript world. So much is evolving so quickly. I understand why you want to lock the version in. For what it's worth, I do have a migration guide in the CHANGELOG. If you do find time to elaborate on things that break as a result of the upgrade, let me know. So far it seems others find the guide sufficient.
You can install locally now. just make sure to make a run script "ionic":"ionic" and then do yarn ionic or npm ionic to map it to the local. install cordova locally as well...
ionic will also look for a locally installed CLI and then use it, much like how Angular CLI or gulp CLI works.
Most helpful comment
Sure I will do. Will explain different use cases on why developers need that and the expected functionality. Thanks again