Angular 6: How to install a previous version of Angular project
Asked Answered
H

3

6

How I can install a previous version of Angular project with the current Angular-cli version (Angular 6).

I found a command but is deprecated:

ng new my_project --ng4

Harbard answered 10/5, 2018 at 12:8 Comment(0)
T
6

Since you want to use angular-cli to create new project, you need to install the version of @angular/cli that scaffolds angular 4 project.

Version of @angular/cli which scaffolds the Angular 4 project is 1.4.9.

So, using npm, do npm install @angular/[email protected], then use angular-cli commands.

Trickster answered 10/5, 2018 at 12:19 Comment(9)
But I don't want to remove my current Angular cli version, is just for one project, my others project use the current angular cli versionHarbard
@Ricky, You don't have to remove the current Angular cli version. You can install one version of Angular cli for each folder. There are two ways to install things using NPM: globally —- This drops modules in {prefix}/lib/node_modules, and puts executable files in {prefix}/bin, where {prefix} is usually something like /usr/local. It also installs man pages in {prefix}/share/man, if they’re supplied. locally —- This installs your package in the current working directory. Node modules go in ./node_modules, executables go in ./node_modules/.bin/, and man pages aren’t installed at all.Trickster
@Ricky , as long as you install the npm package locally with out using -g flag, you are fine. If you install a package with specific version on a directory, only that directory will have the package with the version you have just installed.For reference -> https://nodejs.org/en/blog/npm/npm-1-0-global-vs-local-installation/Trickster
Oh It's very helpful your answer and I din't know that. Thank you very much.Harbard
I have a aditional question: Where I can find what version of angular cli is for Angular 5?Harbard
For that you need to look through @angular/cli releases. Goto github, there you can check releases. Then you have to identify the release which scaffolds which version of angular. e.g. @angular/cli version 1.7.x is for Angular 5, etcTrickster
I was installed npm install @angular/[email protected] version of Angular Cli. This create a node_modules folder, in my current directory (where I was installed [email protected]), but when I run ng new myap Angular 6 is installed and I need Angular 5.Harbard
I think that when I run ng new myapp, is taking the global ng, how do I take the version that I installed in my current directory?Harbard
@Ricky, Make sure you have not installed @angular/cli with version greater than 1.7.3, You can check the version with command ng -v. I have tested this, and I can confirm that if you install version 1.7.3 locally, it should work.Trickster
E
2

You can just have package.json with specific version and do npm install and it will install that version. Also you dont need to depend on angular-cli to develop your project.

Other thing is you can remove the latest version of angular-cli and install minor version of it. Then create the project.

Let me explain:

[STEP 0 - OPTIONAL] If you're not sure of the angular-cli version installed in your environment, uninstall it.

npm uninstall -g @angular/cli

Then, run

npm cache clean

or, if you're using npm > 5

npm cache verify

[STEP 1] Install an angular-cli specific version

npm install -g @angular/[email protected]

[STEP 2] Create a project

ng new you-app-name

The resulting white app will be created in the desired angular version.

Earmark answered 10/5, 2018 at 12:18 Comment(1)
Hello, thanks for your answer, but i don't need to uninstall my current angular cli version. I need just to install an Angular 5 project for one project.Harbard
H
0

I found a better answer for me. I share it with you:

How to install Angular 2:

npm install @angular/[email protected] This install the 2.4.0 version

How to install Angular 4:

npm install @angular/[email protected] This install the 4.2.4 version

How to install Angular 5:

npm install @angular/cli@1 This install @angular/[email protected]

All this installations it must be installed as local projects dependencies

I hope you find it useful.

Harbard answered 3/12, 2018 at 22:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.