简体   繁体   English

调试ionic3应用程序以使用--prod标志进行构建

[英]Debug ionic3 app for building it with --prod flag

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. 有一阵子,我没有使用--prod标志构建ionic3应用程序,它曾经可以正常工作,但是从那以后我做了很多更改。 Now when I run ionic cordova build android --prod I get this error message: 现在,当我运行ionic cordova build android --prod以下错误消息:

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. 该应用程序无需--prod标志即可构建并正常运行。

I understand the problem comes from an undefined property that could not be read and therefore typescript refuse to compile the code. 我知道问题来自无法读取的未定义属性,因此Typescript拒绝编译代码。

My problem is that I've no idea where that length property is in my app, since there are plenty of them. 我的问题是我不知道该length属性在我的应用程序中的什么位置,因为其中有很多。 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? 有没有一种方法可以从打字稿或离子键获取有关该属性在代码中的位置的更多信息,以便我可以更正此错误并能够使用--prod标志构建应用程序?

It seems a problem with one of your node_modules item or items. 您的一个或node_modules项目似乎有问题。 So delete node_modules folder and then run npm i 因此, 删除 node_modules文件夹,然后运行npm i

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM