How to create a project in Ionic v4

I want to start playing with new Ionic v4. What do I have to do create a new project in it.

I have updated the global install by doing npm install -g ionic@4.0.0-rc.5.

So now if I do ionic -v I get 4.0.0-rc.5.

When I create a new project with New cli installed by doing ionic start newproj blank I get the following in my package.json.

  "dependencies": {
    "@angular/animations": "5.2.10",
    "@angular/common": "5.2.10",
    "@angular/compiler": "5.2.10",
    "@angular/compiler-cli": "5.2.10",
    "@angular/core": "5.2.10",
    "@angular/forms": "5.2.10",
    "@angular/http": "5.2.10",
    "@angular/platform-browser": "5.2.10",
    "@angular/platform-browser-dynamic": "5.2.10",
    "@ionic-native/core": "4.7.0",
    "@ionic-native/splash-screen": "4.7.0",
    "@ionic-native/status-bar": "4.7.0",
    "@ionic/storage": "2.1.3",
    "ionic-angular": "3.9.2",
    "ionicons": "3.0.0",
    "rxjs": "5.5.10",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.26"
  }

Note that "ionic-angular": "3.9.2",

Thanks

Never tried it but spontaneously I would say, to create a new project v4 with start, maybe you should also use the upcoming ionic cli?

See readme

👋 👉 Please test ✨ CLI 4 ✨ release candidates: npm i -g ionic@rc ❤️
master (alpha): npm install -g ionic@canary
3.x (stable): npm install -g ionic (recommended) 

but like I said, never tried, just a thought

I have the latest CLI and using start does not give a v4 project. What am I missing here. Can you give it a try and let me know. Thanks.

Unfortunally I will not have the time :frowning: Hope someone could help you

In anycase, you could start the project, then update manually package.json and then remove package-lock.json and node_modules and then npm install and that should do it too

After you install the rc version of the ionic-cli then you’ll have to run
ionic config set -g features.project-angular true to enable ionic angular 4 projects. After you enable that flag just run ionic start and you should see the new angular project template.

3 Likes

Any documentation on this?

I was able to get it working and now the project compiles. But as soon as i do ionic serve i get the following in the browsers

Cannot GET /

in the console I get

Content Security Policy: The page’s settings blocked the loading of a resource at self (“default-src”).

Content Security Policy: The page’s settings blocked the loading of a resource at self (“default-src”). Source: window.klTabId_kis = 'firefox.tab.b7c1db....

Content Security Policy: The page’s settings blocked the loading of a resource at data:font/woff;base64,d09GRgABAAAAAI7kAB... (“default-src”).

How do I solve this?

Not sure, I’ve never seen that error before. How did you go about setting up the project?

Creating a New Ionic 4 Project

Before you can create a new Ionic 4 project go ahead and install the latest version of Ionic CLI (v4) using the following command from your terminal:

npm install -g ionic

After installing the Ionic CLI 4. You can now run the following command to generate a new Ionic 4 project based on Angular 6:

ionic start ionic4upgradedemo blank --type=angular

Creating a new Ionic 4 project based on Angular is the first step toward migrating your Ionic 3 application to Ionic 4 (with Angular). To generate a project based on Angular we are using --type=angular .

1 Like

That’s wrong I think, no need to install the CLI RC version anymore, the cli v4 was official published

 npm install -g ionic
1 Like

Sorry for my Misunderstanding.
thanks.

I was confused by this too, but it seems you have to specify the project type by adding --type=angular to the command line.
You can see all the types with the command :-
ionic start --list
The default seems to be ionic-angular which are the ionic 3 templates.

2 Likes

So…

  1. The command
    ionic start myApp tabs--type=angular
    creates Ionic 4 project

  2. The command:
    ionic start myApp tabs--type=ionic-angular
    creates a Ionic 3 project.

Is this right?

8 Likes

Yes, that is correct.

2 Likes

Is writing --type=angular important?