问题
For a while, I didn't build my ionic3 app with --prod flag, it used to work fine, but I've made quite a few changes since that. Now when I run ionic cordova build android --prod I get this error message:
TypeError: Cannot read property 'length' of undefined
at Object.unescapeIdentifier (/path/to/my/app/node_modules/@angular/compiler-cli/node_modules/typescript/lib/typescript.js:10550:26)
at getTextOfNode (/path/to/my/app/node_modules/@angular/compiler-cli/node_modules/typescript/lib/typescript.js:68575:27)
at emitIdentifier (/path/to/my/app/node_modules/@angular/compiler-cli/node_modules/typescript/lib/typescript.js:66931:19)
at pipelineEmitUnspecified (/path/to/my/app/node_modules/@angular/compiler-cli/node_modules/typescript/lib/typescript.js:66594:28)
at pipelineEmitWithHint (/path/to/my/app/node_modules/@angular/compiler-cli/node_modules/typescript/lib/typescript.js:66566:50)
at pipelineEmitWithSourceMap (/path/to/my/app/node_modules/@angular/compiler-cli/node_modules/typescript/lib/typescript.js:66558:17)
at emitNodeWithComments (/path/to/my/app/node_modules/@angular/compiler-cli/node_modules/typescript/lib/typescript.js:64200:17)
at pipelineEmitWithComments (/path/to/my/app/node_modules/@angular/compiler-cli/node_modules/typescript/lib/typescript.js:66547:17)
at pipelineEmitWithNotification (/path/to/my/app/node_modules/@angular/compiler-cli/node_modules/typescript/lib/typescript.js:66541:17)
at emit (/path/to/my/app/node_modules/@angular/compiler-cli/node_modules/typescript/lib/typescript.js:66528:13)
The app builds and run fine without --prod flag.
I understand the problem comes from an undefined property that could not be read and therefore typescript refuse to compile the code.
My problem is that I've no idea where that length property is in my app, since there are plenty of them.
Is there a way to get more info about where that property is situated in my code, from typescript or ionic, so that I can correct this error and be able to build the app with --prod flag?
回答1:
It seems a problem with one of your node_modules item or items. So delete node_modules folder and then run npm i
来源:https://stackoverflow.com/questions/47680149/debug-ionic3-app-for-building-it-with-prod-flag