Error after macOS/Xcode Update

I updated macOS (11.6) and Xcode (13.0) last weekend and after that my Ionic app does not compile any longer.

When I run the command “ionic cordova build ios” I get the following output:

ng run app:ionic-cordova-build:production --platform=ios
An unhandled exception occurred: Cannot find module ‘@ionic/angular-toolkit/package.json’
Require stack:
- /Users/ralf/n/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js
- /Users/ralf/n/lib/node_modules/@angular/cli/node_modules/@angular-devkit/architect/node/index.js
- /Users/ralf/n/lib/node_modules/@angular/cli/models/architect-command.js
- /Users/ralf/n/lib/node_modules/@angular/cli/commands/run-impl.js
- /Users/ralf/n/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/export-ref.js
- /Users/ralf/n/lib/node_modules/@angular/cli/node_modules/@angular-devkit/schematics/tools/index.js
- /Users/ralf/n/lib/node_modules/@angular/cli/utilities/json-schema.js
- /Users/ralf/n/lib/node_modules/@angular/cli/models/command-runner.js
- /Users/ralf/n/lib/node_modules/@angular/cli/lib/cli/index.js
- /Users/ralf/n/lib/node_modules/@angular/cli/lib/init.js
- /Users/ralf/n/lib/node_modules/@angular/cli/bin/ng
See “/private/var/folders/y7/p3fxhqk92d30gbk09x6_w5480000gn/T/ng-8Mvwyk/angular-errors.log” for further details.
[ ERROR ] An error occurred while running subprocess ng .

@ionic/angular-toolkit/package.json’ is available in node_modules of my project.

This is the output of “ionic info”:

Ionic:

Ionic CLI : 6.16.3 (/Users/ralf/n/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.8.1
@angular-devkit/build-angular : 12.2.7
@angular-devkit/schematics : 12.2.7
@angular/cli : 12.2.7
@ionic/angular-toolkit : 4.0.0

Cordova:

Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.0.0, ios 5.0.1
Cordova Plugins : cordova-plugin-ionic-webview 4.1.3, (and 15 other plugins)

Utility:

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

System:

ios-deploy : 1.9.2
NodeJS : v14.17.0 (/Users/ralf/n/bin/node)
npm : 7.21.1
OS : macOS Big Sur
Xcode : Xcode 13.0 Build version 13A233

Any ideas how to solve this problem?

I think it has nothing to do with the macOS/Xcode update. When I create a new project with the Ionic cli and add the ios platfrom everything works fine. No build error. Must be related to my specific project.

have you tried removing node_modules and package-lock.json and installing again?

Yes, that was my first try, but without any success :frowning:

I solved the problem. The problem was that I had angular installed globally and the “ionic build” tried to use the global ng version.

After removing the global angular version “ionic build” complaint about a missing @angular/cli. What is strange, because @angular/cli is listed in package.json.

Anyway, after installing it with the proposed npm command the build runs again.

@angular/cli is supposed to be installed globally. I would suggest using nvm to manage your node installations. It makes problems like this less likely to happen in the first place and much easier to clean up when they do.