user10068249
user10068249

Reputation:

How to generate a new Angular 4 project instead of creating generating Angular 6?

I recently just installed Angular on my Ubuntu 16.04 computer following the documentation found here. But when i generate a new Angular project, it generates Angular 6.

How do i generate specific angular 4 project?

Upvotes: 6

Views: 1449

Answers (3)

Shubham Verma
Shubham Verma

Reputation: 9933

You need to do following things to create an app with your choice:

Step 1. Set up the Development Environment:

You need to set up your development environment before you can do anything. Install Node.js and npm if they are not already on your machine.

Step 2: Then install the Angular CLI globally.

> npm install -g @angular/[email protected].*

Step 3: Create a new project

> ng new my-app

Step 4: Serve the application:

> cd my-app

> ng serve --open

The above app will be in angular 4.

Upvotes: 0

Rohan Kumar
Rohan Kumar

Reputation: 40639

Try the follow command in your project folder,

npm install @angular/[email protected]

Read the changelog

And if you want to change the CLI version globally then use -g in npm install command.

Another way to do is that

1.Remove/Rename the node_modules folder of your project.

2.Change the dependencies in your package.json file to

 "dependencies": {
        "@angular/common": "4.1.3",
        "@angular/compiler": "4.1.3",
        "@angular/compiler-cli": "4.1.3",
        "@angular/core": "4.1.3",
        "@angular/forms": "4.1.3",
        "@angular/http": "4.1.3",
        "@angular/platform-browser": "4.1.3",
        "@angular/platform-browser-dynamic": "4.1.3",
        "@angular/tsc-wrapped": "^4.4.6",
        "rxjs": "5.4.0",
        "zone.js": "0.8.12"
    },

3. Then run command 'npm install` in the folder where you have created your app.

Upvotes: 0

Dale
Dale

Reputation: 619

You can following these steps to generate an Angular 4 project

> npm remove -g @angular/cli
> npm install -g @angular/[email protected]
> ng --version
  @angular/cli: 1.4.10
> ng new myangular4

Assuming that you already have angular cli installed in your system, the steps above will remove the current angular cli installed an will be replaced by an angular cli that can generate Angular 4.

Upvotes: 8

Related Questions