How do I create new project with the latest Angular 4 release using Angular CLI with the command below :
ng new new_project
I have the following versions installed
 - @angular/cli: 1.0.0-rc.2
 - node: 7.7.3
 - npm: 4.4.1
                The other method to create Angular application in a specific version is to use npx command that executes npm package binaries. Then we just need to execute npx command with the -p parameter where we put a specific @angular/cli version.
Angular4 uses TypeScript 2.2 version whereas Angular 2 uses TypeScript version 1.8. This brings a lot of difference in the performance. To install Angular 4, the Angular team came up with Angular CLI which eases the installation.
Now open Visual Studio Code. Go to "File" > "Open Folder" and select "First-Angular-Project" from the "Desktop". Now in the "TERMINAL" run ng new Angular-Project-Demo. Whenever it prompts with something like "Would you like to add Angular routing? (y/N)" press "y" and hit "ENTER".
You cannot create a new Angular application with the CLI that uses Angular 4 out of the box. At least, not at the moment. Only Angular 2 is supported by the CLI, at this time. I imagine that will change soon enough.
However, you can create a new application using ng new <app-name>, and then change the version of Angular it uses in the package.json. Run npm install, and it should all work. That has been my experience.
Hope this helps you out.
UPDATE:
I am mistaken! There is an option that you can pass to the ng new command that will set up the project to use ng 4.
ng new project_new --ng4
From ng --help:
--ng4 (Boolean) (Default: false) Create a project with Angular 4 in the template.
Right now this sets up the @angular section package.json as follows.
  "dependencies": {     "@angular/common": ">=4.0.0-beta <5.0.0",     "@angular/compiler": ">=4.0.0-beta <5.0.0",     "@angular/core": ">=4.0.0-beta <5.0.0",     "@angular/forms": ">=4.0.0-beta <5.0.0",     "@angular/http": ">=4.0.0-beta <5.0.0",     "@angular/platform-browser": ">=4.0.0-beta <5.0.0",     "@angular/platform-browser-dynamic": ">=4.0.0-beta <5.0.0",     "@angular/router": ">=4.0.0-beta <5.0.0",     ...   Just tried it, and it works.
UPDATE 2
The --ng4 option has now been removed as the latest CLI will now create an Angular 5 project just by using ng new project_name.
The easiest way to create an Angular 4 project using Angular CLI is install an older version of the @angular/cli (1.4.10)
npx @angular/[email protected] new myangular4
(thanks Explosion Pills)
Or
> npm remove -g @angular/cli
> npm install -g @angular/[email protected]
> ng --version
  @angular/cli: 1.4.10
> ng new myangular4
Creates a myangular4/package.json
{
  "name": "myangular4",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.2.4",
    "@angular/common": "^4.2.4",
    "@angular/compiler": "^4.2.4",
    "@angular/core": "^4.2.4",
    "@angular/forms": "^4.2.4",
    "@angular/http": "^4.2.4",
    "@angular/platform-browser": "^4.2.4",
    "@angular/platform-browser-dynamic": "^4.2.4",
    "@angular/router": "^4.2.4",
    "core-js": "^2.4.1",
    "rxjs": "^5.4.2",
    "zone.js": "^0.8.14"
  },
                        Update your angular-cli version, then try to use "ng new new_project" command to create new angular 4 application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With