user1669296
user1669296

Reputation: 445

Ionic 2 - Can't generate pages via the CLI how to resolve error?

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

Upvotes: 6

Views: 4663

Answers (4)

Esom
Esom

Reputation: 11

npm i -g [email protected] resolved the issue for me, was previously on ionic 2.0.0 beta 11

Upvotes: 0

user1278228
user1278228

Reputation: 111

npm i -g [email protected] - Solved the issue.

Thank you.

Upvotes: 0

Stefan Rein
Stefan Rein

Reputation: 9062

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

Upvotes: 0

Shruti Saagar
Shruti Saagar

Reputation: 89

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.

Upvotes: 2

Related Questions