Facing the same issue here is my package.json , Ionic serve is fine no error, ionic cordova build android --prod --release fails with bellow error
[00:35:35] ionic-app-script task: "build"
[00:35:35] Error: Cannot find module '@angular/compiler-cli/ngtools2' Require stack: -
/media/peter/Media/projects/v3/stockappadmin/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js -
/media/peter/Media/projects/v3/stockappadmin/node_modules/@ionic/app-scripts/dist/ngc.js -
/media/peter/Media/projects/v3/stockappadmin/node_modules/@ionic/app-scripts/dist/build.js -
/media/peter/Media/projects/v3/stockappadmin/node_modules/@ionic/app-scripts/dist/index.js -
/media/peter/Media/projects/v3/stockappadmin/node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js
Error: Cannot find module '@angular/compiler-cli/ngtools2'
Require stack:
- /media/peter/Media/projects/v3/stockappadmin/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js
- /media/peter/Media/projects/v3/stockappadmin/node_modules/@ionic/app-scripts/dist/ngc.js
- /media/peter/Media/projects/v3/stockappadmin/node_modules/@ionic/app-scripts/dist/build.js
- /media/peter/Media/projects/v3/stockappadmin/node_modules/@ionic/app-scripts/dist/index.js
- /media/peter/Media/projects/v3/stockappadmin/node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
at Function.Module._load (internal/modules/cjs/loader.js:864:27)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at /media/peter/Media/projects/v3/stockappadmin/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:206:90
{
"name": "myapp",
"version": "0.0.1",
"author": "me",
"homepage": "http://me.app/",
"private": true,
"scripts": {
"start": "ionic-app-scripts serve",
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"@angular/animations": "5.2.11",
"@angular/common": "5.2.11",
"@angular/compiler": "5.2.11",
"@angular/compiler-cli": "^9.0.7",
"@angular/core": "5.2.11",
"@angular/forms": "5.2.11",
"@angular/http": "5.2.11",
"@angular/platform-browser": "5.2.11",
"@angular/platform-browser-dynamic": "5.2.11",
"@ionic-native/app-update": "^4.20.0",
"@ionic-native/call-number": "^4.20.0",
"@ionic-native/core": "~4.18.0",
"@ionic-native/native-audio": "^4.20.0",
"@ionic-native/photo-library": "^5.8.0",
"@ionic-native/push": "^4.20.0",
"@ionic-native/splash-screen": "~4.18.0",
"@ionic-native/status-bar": "~4.18.0",
"@ionic/storage": "2.2.0",
"@swimlane/ngx-datatable": "^15.0.2",
"@types/html2canvas": "0.0.35",
"@types/jspdf": "^1.3.0",
"angular-datatables": "^8.0.0",
"call-number": "^1.0.1",
"chart.js": "^2.8.0",
"cordova-android": "8.1.0",
"cordova-android-support-gradle-release": "^3.0.1",
"cordova-browser": "5.0.4",
"cordova-plugin-app-update": "^2.0.2",
"cordova-plugin-appversion": "^1.0.0",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-file": "^6.0.1",
"cordova-plugin-file-opener2": "^2.1.4",
"cordova-plugin-ionic-keyboard": "^2.1.3",
"cordova-plugin-ionic-webview": "^2.5.1",
"cordova-plugin-nativeaudio": "^3.0.9",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-support-google-services": "^1.3.2",
"datatables.net": "^1.10.19",
"datatables.net-dt": "^1.10.19",
"firebase": "^6.3.5",
"html2canvas": "^1.0.0-rc.3",
"ionic-angular": "3.9.2",
"ionic-select-searchable": "^2.10.0",
"ionic-selectable": "^3.4.2",
"ionic2-super-tabs": "^5.2.0",
"ionic3-calendar-en": "^1.1.3",
"ionicons": "3.0.0",
"jodit": "^3.2.45",
"jquery": "^3.4.1",
"moment": "^2.24.0",
"mx.ferreyra.callnumber": "~0.0.2",
"ngx-pipes": "^2.5.1",
"node-sass": "^4.13.0",
"phonegap-plugin-multidex": "^1.0.0",
"phonegap-plugin-push": "^2.3.0",
"rxjs": "6.0.0",
"rxjs-compat": "6.0.0",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.26"
},
"devDependencies": {
"@angular-devkit/build-optimizer": "^0.12.4",
"@ionic/lab": "^3.1.2",
"@types/datatables.net": "^1.10.17",
"@types/jquery": "^3.3.30",
"@ionic/app-scripts": "3.2.4",
"typescript": "~2.6.2"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-ionic-keyboard": {},
"cordova-android-support-gradle-release": {
"ANDROID_SUPPORT_VERSION": "27.+"
},
"cordova-plugin-app-update": {},
"cordova-plugin-file-opener2": {
"ANDROID_SUPPORT_V4_VERSION": "27.+"
},
"cordova-plugin-file": {},
"cordova-plugin-nativeaudio": {},
"mx.ferreyra.callnumber": {},
"phonegap-plugin-push": {}
},
"platforms": [
"browser",
"android"
]
}
}