# iOnic CLI 3 Generator

**URL:** <https://forum.ionicframework.com/t/ionic-cli-3-generator/85775>\
**Category:** ionic-v3\
**Created:** [April 7, 2017, 3:24pm UTC](https://forum.ionicframework.com/t/ionic-cli-3-generator/85775 "2017-04-07T15:24:40Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![LoLStats](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/lolstats/32/103165_2.png) [@LoLStats](https://forum.ionicframework.com/u/LoLStats)\
**Post date:** [April 7, 2017, 3:24pm UTC](https://forum.ionicframework.com/t/ionic-cli-3-generator/85775/1 "2017-04-07T15:24:40Z")

</div>

I updated to iOnic 3 and also to the New Ionic CLI v3.

Because the documentation about the new version is not the best, I can’t find out how to generate components, pages or providers.

I hope somebody can help me 🙂

I found a workaround to generate my providers without errors.

I just type `ionic generate`, select provider, give it a name and then select `Use this provider in more than one template?` with `Yes`

---

<div class="post-metadata">

**Author:** ![JAR19](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/jar19/32/113216_2.png) [@JAR19](https://forum.ionicframework.com/u/JAR19)\
**Post date:** [April 7, 2017, 4:00pm UTC](https://forum.ionicframework.com/t/ionic-cli-3-generator/85775/2 "2017-04-07T16:00:55Z")

</div>

Just type in the command **ionic generate**

---

<div class="post-metadata">

**Author:** ![shepard](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@shepard](https://forum.ionicframework.com/u/shepard)\
**Post date:** [April 7, 2017, 4:03pm UTC](https://forum.ionicframework.com/t/ionic-cli-3-generator/85775/3 "2017-04-07T16:03:49Z")

</div>

I tried:  
`ionic generate page test`

Got error:  
`Error: The generate command is only available for projects that use ionic-angular >= 3.0.0`

package.json contains:  
`"ionic-angular": "3.0.0-beta.3"`

---

<div class="post-metadata">

**Author:** ![asterus](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/asterus/32/88585_2.png) [@asterus](https://forum.ionicframework.com/u/asterus)\
**Post date:** [April 7, 2017, 4:06pm UTC](https://forum.ionicframework.com/t/ionic-cli-3-generator/85775/4 "2017-04-07T16:06:07Z")

</div>

What stops you updating to 3.0.1?

---

<div class="post-metadata">

**Author:** ![shepard](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@shepard](https://forum.ionicframework.com/u/shepard)\
**Post date:** [April 7, 2017, 4:08pm UTC](https://forum.ionicframework.com/t/ionic-cli-3-generator/85775/5 "2017-04-07T16:08:14Z")

</div>

Nothing - now that I know it is available.  
So, you are saying that 3.0.0 does Not work but 3.0.1 does?

---

<div class="post-metadata">

**Author:** ![LoLStats](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/lolstats/32/103165_2.png) [@LoLStats](https://forum.ionicframework.com/u/LoLStats)\
**Post date:** [April 7, 2017, 4:11pm UTC](https://forum.ionicframework.com/t/ionic-cli-3-generator/85775/6 "2017-04-07T16:11:19Z")

</div>

I can generate pages when I just type `ionic generate`

Then this page shows up

```
? What would you like to generate: (Use arrow keys)
❯ component 
  directive 
  page 
  pipe 
  provider 
  tabs 

```

No problems when I want to generate a page or component. But I can’t generate any provider without errors. I select for example my login page and then this error shows up

```
TypeError: Cannot read property 'initializer' of undefined
at Object.appendNgModuleDeclaration (/Users/daniel/Documents/Projekte/Cinematica/node_modules/@ionic/app-scripts/dist/util/typescript-utils.js:212:38)
at /Users/daniel/Documents/Projekte/Cinematica/node_modules/@ionic/app-scripts/dist/generators/util.js:161:46
```

---

<div class="post-metadata">

**Author:** ![shepard](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@shepard](https://forum.ionicframework.com/u/shepard)\
**Post date:** [April 7, 2017, 4:18pm UTC](https://forum.ionicframework.com/t/ionic-cli-3-generator/85775/7 "2017-04-07T16:18:09Z")

</div>

I updated to 3.0.1 and using ionic generate works. It provides options for page, provider etc, as LoLStats noted.

Provider Did work for me though. No errors. I chose use in multiple components.  
It automatically injected it into my app.module.ts.

Using 3.0.0-beta.3 did not work.

---

<div class="post-metadata">

**Author:** ![shepard](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@shepard](https://forum.ionicframework.com/u/shepard)\
**Post date:** [April 7, 2017, 4:40pm UTC](https://forum.ionicframework.com/t/ionic-cli-3-generator/85775/8 "2017-04-07T16:40:36Z")

</div>

When a page is generated, it is creating the module.ts but is using the following, which throws an error:

```
IonicModule.forChild(TestPage),

```

Chaning it to this fixes it:

`IonicPageModule.forChild(TestPage),`

I assume this is because of something else I have not updated. Maybe @ionic/app-scripts which I have currently at 1.2.5

How does one find out which is the current package dependencies and devDependencies to update to?  
It is not mentioned for 3.0.1 in the changelog:

> <https://github.com/ionic-team/ionic/blob/master/CHANGELOG.md>

---

<div class="post-metadata">

**Author:** ![shepard](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@shepard](https://forum.ionicframework.com/u/shepard)\
**Post date:** [April 7, 2017, 5:01pm UTC](https://forum.ionicframework.com/t/ionic-cli-3-generator/85775/9 "2017-04-07T17:01:28Z")

</div>

Also, concerning the provider generated, while it did include it in the app.module.ts, on windows, it is wrong.

I created a provider called MapService which gives me this runtime error:  
`Cannot find module "..providersmap-service/map-service"`

The genrated line in the app.module was:  
`import { MapServiceProvider } from '..\providers\map-service/map-service';`

However, this works ( slashes):  
`import { MapServiceProvider } from '../providers/map-service/map-service';`

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [April 8, 2017, 3:10am UTC](https://forum.ionicframework.com/t/ionic-cli-3-generator/85775/10 "2017-04-08T03:10:16Z")

</div>

Frankly, I would avoid the generators.
