Ionic Info
Run ionic info from a terminal/cmd prompt and paste the output below.
ionic info
Ionic:
ionic (Ionic CLI) : 4.0.1 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.0-beta.0
@angular-devkit/core : 0.7.0
@angular-devkit/schematics : 0.7.0
@angular/cli : 6.1.0
@ionic/ng-toolkit : 1.0.0
@ionic/schematics-angular : 1.0.1
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : none
System:
Android SDK Tools : 26.1.1
ios-deploy : 1.9.2
NodeJS : v10.2.1 (/usr/local/bin/node)
npm : 6.2.0
OS : macOS High Sierra
Xcode : Xcode 9.4.1 Build version 9F2000
Environment:
ANDROID_HOME : /Users/max/Library/Android/sdk
Describe the Bug
Running ng g s services/serviceName gives the following error: newTree.optimize is not a function.
This happens only with Ionic 4
Steps to Reproduce
Steps to reproduce the behavior:
Just generate Ionic4 project and try to generate a service file with Angular CLI
@mruknowme What is the output of which ng?
@dwieeb
/usr/local/bin/ng
ng -v
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ â–³ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 6.1.0
Node: 10.2.1
OS: darwin x64
Angular: 6.1.0
... cli, common, compiler, compiler-cli, core, forms, http
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.7.0
@angular-devkit/build-angular 0.7.0
@angular-devkit/build-optimizer 0.7.0
@angular-devkit/build-webpack 0.7.0
@angular-devkit/core 0.7.0
@angular-devkit/schematics 0.7.0
@ngtools/webpack 6.1.0
@schematics/angular 0.6.8
@schematics/update 0.7.0
rxjs 6.2.2
typescript 2.7.2
webpack 4.9.2
Looks like the issue is in 0.7.0 of the Angular devkit.
So there is no problem in earlier versions? (This one ships with Angular CLI 6.1.0)
I'm getting the same issue - seems to be with all generate commands except page. Both ionic g page and ng generate page will work, but service, component, directive, pipe won't.
Please apply these version changes to your projects or start a new project once the starters are finished deploying ~10min (wait for green check mark on latest commit: https://github.com/ionic-team/starters/commits/master)
I created an issue to attempt to avoid issues like this in the future: https://github.com/ionic-team/starters/issues/358
Thanks, and apologies for that.
Ok, no problem, will try soo and let you know if I face further issues. Thank you!
Can confirm it works now - thanks!
I think I can close this, right?
Most helpful comment
Please apply these version changes to your projects or start a new project once the starters are finished deploying ~10min (wait for green check mark on latest commit: https://github.com/ionic-team/starters/commits/master)
I created an issue to attempt to avoid issues like this in the future: https://github.com/ionic-team/starters/issues/358
Thanks, and apologies for that.