20

If I do ionic generate component xxx

An unhandled exception occurred: Cannot find module '@schematics/angular/utility/project' Require stack:

  • /Users/user/develop/myapp/node_modules/@ionic/angular-toolkit/schematics/component/index.js

  • /Users/user/develop/myapp/node_modules/@angular-devkit/schematics/tools/export-ref.js

  • /Users/user/develop/myapp/node_modules/@angular-devkit/schematics/tools/index.js

  • /Users/user/develop/myapp/node_modules/@angular/cli/utilities/json-schema.js

  • /Users/user/develop/myapp/node_modules/@angular/cli/models/command-runner.js

  • /Users/user/develop/myapp/node_modules/@angular/cli/lib/cli/index.js

  • /Users/user/develop/myapp/node_modules/@angular/cli/lib/init.js

  • /Users/user/develop/myapp/node_modules/@angular/cli/bin/ng

    Ionic:

     Ionic CLI                     : 6.10.1 (/usr/local/lib/node_modules/@ionic/cli)
     Ionic Framework               : @ionic/angular 5.2.3
     @angular-devkit/build-angular : 0.1000.2
     @angular-devkit/schematics    : 10.0.2
     @angular/cli                  : 10.0.2
     @ionic/angular-toolkit        : 2.2.0
    

    Capacitor:

     Capacitor CLI   : 2.1.2
     @capacitor/core : 2.1.2
    

    Cordova:

     Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
     Cordova Platforms : android 8.1.0
     Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 7 other plugins)
    

    Utility:

     cordova-res : not installed
     native-run  : not installed
    

    System:

     ios-sim : 8.0.2
     NodeJS  : v12.18.1 (/usr/local/bin/node)
     npm     : 6.14.6
     OS      : macOS Catalina
     Xcode   : Xcode 11.5 Build version 11E608c
    

8 Answers8

62

Seems like it's an ionic incompatibility with angular 10+

THIS WORKED FOR ME

npm uninstall @schematics/angular
npm install @schematics/angular@9.1.0
Abbas Fatullaev
  • 721
  • 4
  • 4
7

You may first proceed with npm uninstall @schematics/angular and TERMINAL informs that "removed XX packages and audited XXXX packages" etc, then you may implement npm install @schematics/angular@9.1.0.

Accordingly, ng add ngx-bootstrap provides:

✅️ Added "bootstrap

✅️ Added "ngx-bootstrap

Vibhu khurana
  • 71
  • 1
  • 2
3

Try the code below

npm install @angular-devkit/schematics @angular-devkit/core @schematics/angular
vimuth
  • 5,064
  • 33
  • 79
  • 116
shine odigie
  • 156
  • 1
  • 6
2

In my case it was to have this:

"@ionic/angular-toolkit": "^2.3.3" 

instead of "^2.2.0"

My Angular: 10.1.4.

I found this out by creating fresh Ionic project after upgrading Ionic CLI to newest.

KarolDepka
  • 8,318
  • 10
  • 45
  • 58
2

The problem is schematics module incompatibility.

  1. Find out the version of the @schematics/angular
node_modules/@schematics/angular/package.json/#_from
  1. Find out the version of @schematics/angular which used in the @ionic/angular-toolkit module.
node_modules/@ionic/angular-toolkit/package.json

// package.json 

"dependencies": {
    "@schematics/angular": "^11.2.4",  
}
  1. Make sure the versions are matching.

  2. If the versions do not match, then install the matching version of @schematics/angular.

  3. Have an awesome day!

Ahmet Emrebas
  • 566
  • 6
  • 10
  • This kinda worked for me, but it was a very nice first step to find my information. After studying how the Angular team setup their version name, I just used whatever version of Angular I was using at the moment. As of today, I am still on Angular 13, so I used the @schematics/angular pertaining to the version `^13.2.2`. I did the same with the `@angular/pwa` package, since the latest is not compatible with Angular 13. – Esteban Morales Feb 02 '23 at 00:11
2

can you please try to run ng add @angular/pwa@13?

user9088454
  • 1,076
  • 1
  • 15
  • 45
0

This worked for me.

npm i --save-dev @nativescript/schematics
Dharman
  • 30,962
  • 25
  • 85
  • 135
0

In my case, after failing with all kind of suggestions.
I update npm: https://www.hostingadvice.com/how-to/update-node-js-latest-version/

Later on Angular: https://update.angular.io/?v=13.0-14.0 and Ionic: https://ionicframework.com/docs/intro/upgrading-to-ionic-6

It works!!

Greg SP
  • 256
  • 2
  • 3