6

This may be just my lack of experience working with ionic 2 but I'm getting an error when tying to generate pages via the CLI.

The syntax I'm using: "ionic g page TestPage"

It returns an error (below). Does anyone know how to resolve this error? It seems the "templates" directory does not exist on my machine which I gather is why this is happening, but not sure how to get it there or fix the issue. The first part of the path does exist: C:\apps\sampleapp\node_modules\ionic-angular\, but not the "templates/page" part.

Error: ENOENT: no such file or directory, scandir 'C:\apps\sampleapp\node_modules\ionic-angular\templates\page'
at Error (native)
at Object.fs.readdirSync (fs.js:808:18)
at getTemplatesInDir (C:\Users\m411\AppData\Roaming\npm\node_modules\ionic\node_modules\@ionic\app-generator
at Generator.renderAndWriteTemplates (C:\Users\m411\AppData\Roaming\npm\node_modules\ionic\node_modules\@ion
at C:\Users\m411\AppData\Roaming\npm\node_modules\ionic\node_modules\@ionic\app-generators\index.js:25304:26

Ionic Framework Version: 2.0.0-beta.11

Ionic CLI Version: 2.1.0-beta.1

Ionic App Lib Version: 2.1.0-beta.0

OS: Windows 8.1

Node Version: v4.5.0

user1669296
  • 425
  • 1
  • 6
  • 13
  • Do you have ionic-angular/templates directory in your node modules? Did you npm install properly? – misha130 Sep 17 '16 at 07:23
  • No @misha130 - The templates directory is missing. I'm not sure why or what causes it to be there unfortunately. I did run "npm install" in my project directory, but the folder you mentioned is not there – user1669296 Sep 17 '16 at 07:29
  • Actually I checked and for me its located in tooling/generators instead of templates/. Maybe switch down to Ionic CLI version 2.0.0 beta 32? – misha130 Sep 17 '16 at 07:50
  • Faced the same issue with Ionic '2.1.0-beta.1'. I swichted to Ionic version 2.0.0. Its working now. Please try that. – Madhukar Sep 17 '16 at 11:38
  • Thanks for the help here guys, how can I downgrade my version @Madhukar? – user1669296 Sep 17 '16 at 17:05
  • 1
    To downgrade your `ionic` *version* just run the following: `npm i -g ionic@2.0.0-beta.37`. – developer033 Sep 19 '16 at 00:40
  • 1
    I would suggest going for `npm i -g ionic@2.0.0`. Hope this would help. – Madhukar Sep 23 '16 at 16:28

4 Answers4

2

Downgrade your ionic version to beta 22.. I think it works by uninstalling and then updating npm just in case and then reinstalling a lower ionic version.

How do you completely remove Ionic and Cordova installation from mac?

And I would suggest trying "npm install" in the project directory after this too.

Community
  • 1
  • 1
Shruti Saagar
  • 79
  • 1
  • 11
0

npm i -g ionic@2.0.0 - Solved the issue.

Thank you.

CodeChanger
  • 7,953
  • 5
  • 49
  • 80
user1278228
  • 101
  • 3
  • 12
0

Okay, for anyone where downgrading is not an option:

The Ionic Team did some major API updates and some restructuring. You need to follow these upgrade steps:

Sidenote: If you did uninstall and reinstall the package AND did run the command with sudo and hit the command ionic start --v2 myApp in the same terminal, then you need to update the rights in your folder with: sudo chown -R username ./pathToAppFolder

https://github.com/driftyco/ionic/blob/master/CHANGELOG.md#steps-to-upgrade-to-rc0

Stefan Rein
  • 8,084
  • 3
  • 37
  • 37
0

npm i -g ionic@2.0.0-beta.37 resolved the issue for me, was previously on ionic 2.0.0 beta 11

CodeChanger
  • 7,953
  • 5
  • 49
  • 80
Esom
  • 11
  • 1