I try to run my app with --prod, but I throw this error, TypeError: Cannot read property 'codeGen' of undefined


#1
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'ionic:build',
1 verbose cli   '--',
1 verbose cli   '--prod' ]
2 info using npm@3.10.10
3 info using node@v6.9.4
4 verbose run-script [ 'preionic:build', 'ionic:build', 'postionic:build' ]
5 info lifecycle ionic-hello-world@~preionic:build: ionic-hello-world@
6 silly lifecycle ionic-hello-world@~preionic:build: no script for preionic:build, continuing
7 info lifecycle ionic-hello-world@~ionic:build: ionic-hello-world@
8 verbose lifecycle ionic-hello-world@~ionic:build: unsafe-perm in lifecycle true
9 verbose lifecycle ionic-hello-world@~ionic:build: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;D:\Work\StudioEducativo\StudioEdu\Studioeducativo-movil\StudioEducativo\node_modules\.bin;C:\Users\ASUS\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\ASUS\bin;C:\ProgramData\Oracle\Java\javapath;C:\Python27;C:\Python27\Scripts;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Skype\Phone;C:\Program Files\Git\cmd;C:\xampp\php;C:\ProgramData\ComposerSetup\bin;C:\Program Files\nodejs;C:\apache-ant-1.10.0\bin;C:\Program Files\Java\jdk1.8.0\bin;D:\sdk\platform-tools;D:\sdk\tools;C:\Program Files (x86)\AMD\ATI.ACE\Core-Static;C:\Users\ASUS\AppData\Roaming\Python\Scripts;C:\Users\ASUS\AppData\Local\Microsoft\WindowsApps;C:\Users\ASUS\AppData\Roaming\Composer\vendor\bin;C:\Users\ASUS\AppData\Roaming\npm;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
10 verbose lifecycle ionic-hello-world@~ionic:build: CWD: D:\Work\StudioEducativo\StudioEdu\Studioeducativo-movil\StudioEducativo
11 silly lifecycle ionic-hello-world@~ionic:build: Args: [ '/d /s /c', 'ionic-app-scripts build "--prod"' ]
12 silly lifecycle ionic-hello-world@~ionic:build: Returned: code: 1  signal: null
13 info lifecycle ionic-hello-world@~ionic:build: Failed to exec ionic:build script
14 verbose stack Error: ionic-hello-world@ ionic:build: `ionic-app-scripts build "--prod"`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:255:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:191:7)
14 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:191:7)
14 verbose stack     at maybeClose (internal/child_process.js:877:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid ionic-hello-world@
16 verbose cwd D:\Work\StudioEducativo\StudioEdu\Studioeducativo-movil\StudioEducativo
17 error Windows_NT 10.0.14393
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "ionic:build" "--" "--prod"
19 error node v6.9.4
20 error npm  v3.10.10
21 error code ELIFECYCLE
22 error ionic-hello-world@ ionic:build: `ionic-app-scripts build "--prod"`
22 error Exit status 1
23 error Failed at the ionic-hello-world@ ionic:build script 'ionic-app-scripts build "--prod"'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the ionic-hello-world package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     ionic-app-scripts build "--prod"
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs ionic-hello-world
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls ionic-hello-world
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

#2

You were lucky with that?


#3

I get the same error. Tried updating npm, ionic, app-scripts but still the same result.
It was giving issue with plugin earlier, updating app-scripts solved but now build fails with ‘codeGen’ property issue.

@feliperoan, did you get any solution on it?


#4

Same error, did you find a solution?


#5

I have the same issue. It happens when I run

ionic run android --prod


#6

Post your output of ionic info and content of package.json please. Then maybe someone can try to understand what is going on.


#7

I found a solution for me, the problem was that I use ionic storage, so I imported it into the providers as a class. As I showed in several places, what I did was remove it from the importation of services and I imported this,

 imports: [
     IonicModule.forRoot(MyApp),
    IonicStorageModule.forRoot()//here
  ],

Instead of:

providers: [Storage ]

This changed by the script versions as far as I know.
I was also calling methods and actions in my component outside of Platform.ready.

It is almost mandatory that all initialization of my app is there as some pugin do not load and there are errors, for example if you initialize a database with the sqlite plugin if it is not there, it will appear that the plugin is not installed-

 You have been opted out of telemetry. To change this, run: cordova telemetry on.
6.5.0

Ionic Framework Version: 2.0.0
Ionic CLI Version: 2.2.2
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.0.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.9.4
Xcode version: Not installed

If you have any questions or errors, they ask me, I had to change other things but I do not remember very well which, I had many mistakes lol.

{
  "name": "ionic-hello-world",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "2.2.1",
    "@angular/compiler": "2.2.1",
    "@angular/compiler-cli": "2.2.1",
    "@angular/core": "2.2.1",
    "@angular/forms": "2.2.1",
    "@angular/http": "2.2.1",
    "@angular/platform-browser": "2.2.1",
    "@angular/platform-browser-dynamic": "2.2.1",
    "@angular/platform-server": "2.2.1",
    "@ionic/storage": "2.0.1",
    "ionic-angular": "2.0.0",
    "ionic-native": "2.4.1",
    "ionicons": "3.0.0",
    "rxjs": "5.0.0-beta.12",
    "sw-toolbox": "3.4.0",
    "zone.js": "0.6.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.0.0",
    "typescript": "2.0.9"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-console",
    "cordova-plugin-statusbar",
    "cordova-plugin-device",
    "ionic-plugin-keyboard",
    "cordova-sqlite-storage"
  ],
  "cordovaPlatforms": [],
  "description": "StudioEducativo: An Ionic project"
}


#8

I solved this problem migrating my app to Ionic 3.0.1, this problem happens by a mismatch between ionic version and angular version, Angular version must be superior to version 2.3.x to work ok, you can take two paths:

  1. update everything to Ionic 3.0.1(Guide: How to update to Ionic 3.X )
  2. update angular version but be careful to use compatible versions.(https://github.com/driftyco/ionic/blob/master/CHANGELOG.md)

BR.