Skip to content

How to Use Angular4 and Angular5 on same computer? #9239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
polyglotinc opened this issue Jan 16, 2018 · 11 comments
Closed

How to Use Angular4 and Angular5 on same computer? #9239

polyglotinc opened this issue Jan 16, 2018 · 11 comments

Comments

@polyglotinc
Copy link

angular-cli (and all its collection of satellite installs) seems to require only one version of Angular development to be going on, on the same computer, especially given that everyone shows installing it globally, and things break when arbitrarily moving existing apps to newer versions of all those npm installs.

So, whether I am mistaken about that or not, where is the documentation that shows how to use the same computer for simultaneously developing different projects with different versions of Angular?

Versions

I happen to be using 1.5.1 but the issue is not particularly version specific.

Desired behavior

Would like it to be completely obvious and turnkey which version of Angular is being invoked for a particular project build/serve,
and, different projects can use different versions of Angular.

Ideally, the global installation of angular-cli should be just fine with that, but otherwise document what needs to be installed where/how/global/dev/whatever to support multiple versions of Angular on the same computer.

@clydin
Copy link
Member

clydin commented Jan 16, 2018

The global install delegates to the local project install so what you are describing already happens. Each project has its own version of the CLI and Angular itself which is dictated by the project’s package dependencies. There’s no action required to enable this behavior.

@polyglotinc
Copy link
Author

hmmm...I guess I am missing something because the commands that now install and use Angular5, are the same ones that used to give you Angular4...so how do I specify for any new project whether I want Ang4 or Ang5 (or this summer Ang6, etc...). And does this capability require any particular version of angular-cli?

@clydin
Copy link
Member

clydin commented Jan 17, 2018

The CLI will generate a project using the latest stable version of Angular. There's not really a compelling use case for supporting and maintaining the generation projects using old versions of Angular. The dependencies of the project can be altered to use Angular 4 (or even 2), if necessary. The latest current version of the CLI supports building Angular version 2 and up.

@polyglotinc
Copy link
Author

The compelling use case is the real world.
Big projects can't change foundations every 6 months. You'd be amazed at how many companies are still stuck on AngularJS. Legacy projects add new developers who need to set up new machines with older versions. This is why real world tool stacks (e.g. Java) still provide versions all the way back to the 1990s... http://www.oracle.com/technetwork/java/javase/archive-139210.html

So, even if it is not a turnkey cmd-line option on ng, there should at least be documentation/instructions for the cmds/params needed to set up AngX environment using the current angular-cli.

@clydin
Copy link
Member

clydin commented Jan 17, 2018

Outside of ng new a global version does nothing more than execute the local project version. This allows a project to define the exact version of the CLI within its own dependencies which will be used to execute commands. Also, the latest version the CLI will build an existing Angular 2/4 project so there is no need to change foundations. And there's no additional setup required.

All previous versions of the CLI and Angular are available via npm/yarn/etc. A list of all stable versions of Angular can be queried via npm show @angular/core@* version, for instance.

It's also important to note that Angular 4.0 and 5.0 are incremental improvements over Angular 2.0. This is in stark contrast to the difference between AngularJS and Angular.

@polyglotinc
Copy link
Author

ok, so do I need to npm install --save-dev @angular/cli into each project for there to be a "local project version" to execute (in addition to the global install)?

@Ristaaf
Copy link

Ristaaf commented Jan 17, 2018

I think you are missing some key points in how angular/cli works: ng new is only used when creating a new project. A project created with ng new will have the version of angular it was created with from there on, no matter which version of angular cli you install globally, this is because a local version of angular/cli is already installed into that project (look at the package.json of a ng newed project and you will see) So the project folder after this is totally self contained and has no connection to the version of angular cli you use globally. (other than as mentioned, the global ng commands will act on the folder you are standing in and trigger the same commands in the local angular cli)

However if a newly hired developer is supposed to work on an existing project that uses an old version of angular, that developer should never do ng new, he/she should just get the project folder from source control or share or however you distribute the project, and then do npm install within the project, then that project will continue to use the angular version defined in the project.

The only time you have a problem is if you need to start a completely new project with an old version of angular.

@polyglotinc
Copy link
Author

@hansl
Copy link
Contributor

hansl commented Jan 23, 2018

Hello, we reviewed this issue and determined that it doesn't fall into the bug report or feature request category. This issue tracker is not suitable for support requests, please repost your issue on StackOverflow using tag angular.

If you are wondering why we don't resolve support issues via the issue tracker, please check out this explanation.

Closing this as it's something we support in the CLI already.

@hansl hansl closed this as completed Jan 23, 2018
@winfredchen
Copy link

The similar case for us is that: we would like to use another component which only works under ng5 at this point, but we get the ng6. Any suggestions?

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants