Ionic build --prod fails (NodeCompilerHostContext is not a constructor)



Since I upgraded from ionic 2.2.1 to the latest 3.9.2 I can not build with “–prod” anymore (when i run it without “–prod” everything is fine).

There is the stack trace:

[10:17:19]  ionic-app-scripts 1.1.4 
[10:17:19]  build prod started ... 
[10:17:19]  clean started ... 
[10:17:19]  clean finished in less than 1 ms 
[10:17:19]  copy started ... 
[10:17:19]  ngc started ... 
[10:17:19]  build prod failed: NodeCompilerHostContext is not a constructor 
[10:17:19]  ionic-app-script task: "build" 
[10:17:19]  TypeError: NodeCompilerHostContext is not a constructor 
TypeError: NodeCompilerHostContext is not a constructor
    at Object.runCodegen (/Users/wander/Documents/EvenMind/Projects/GitLab/GarageAdvisorApplication3/node_modules/@ionic/app-scripts/dist/aot/codegen/codegen-ng23plus.js:12:20)
    at Object.doCodegen (/Users/wander/Documents/EvenMind/Projects/GitLab/GarageAdvisorApplication3/node_modules/@ionic/app-scripts/dist/aot/codegen.js:8:31)
    at /Users/wander/Documents/EvenMind/Projects/GitLab/GarageAdvisorApplication3/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:41:30
    at <anonymous>
npm ERR! errno 1
npm ERR! GarageAdvisor@ ionic:build: `ionic-app-scripts build "--prod"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the GarageAdvisor@ ionic:build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: ...

I have no idea on what is going on and I did not find anything on the web…

System information:

Cordova CLI: 6.0.0 
Ionic Framework Version: 3.9.2
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.4
ios-deploy version: 1.9.2 
ios-sim version: 6.1.2 
OS: macOS Sierra
Node Version: v9.3.0
Xcode version: Xcode 9.2 Build version 9C40b


Fixed by upgrading ionic-app-scripts to 3.1.7 and then:

npm install @angular/{animations,common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router}@'latest' typescript@latest rxjs@'latest'