ionic-team / ionic-team/ionic-cli

"TypeError: Cannot read property 'text' of undefined" when compiling to production

Open
#3,491 1 comment 0 reactions 0 assignees View on GitHub
triage
Dominant language
TypeScript
Stars
2k
Forks
682
PR merge metrics
No merged PRs in 30d

Description

**Description:**
TypeError when compiling to production

**Steps to Reproduce:**
`npm run build --prod --verbose`

**Output:**
```
npm info it worked if it ends with ok
npm verb cli [ '/usr/local/bin/node',
npm verb cli '/usr/local/bin/npm',
npm verb cli 'run',
npm verb cli 'build',
npm verb cli '--prod',
npm verb cli '--verbose' ]
npm info using npm@6.3.0
npm info using node@v8.4.0
npm verb run-script [ 'prebuild', 'build', 'postbuild' ]
npm info lifecycle APP@1.0.0~prebuild: APP@1.0.0
npm info lifecycle APP@1.0.0~build: APP@1.0.0

> APP@1.0.0 build *HIDDEN*
> ionic-app-scripts build

[09:12:22] ionic-app-scripts 3.1.11
[09:12:22] build prod started ...
[09:12:22] clean started ...
[09:12:22] clean finished in less than 1 ms
[09:12:22] copy started ...
[09:12:22] deeplinks started ...
[09:12:23] deeplinks finished in 195 ms
[09:12:23] ngc started ...
[09:12:26] ionic-app-script task: "build"
[09:12:26] TypeError: Cannot read property 'text' of undefined
TypeError: Cannot read property 'text' of undefined
at exportedIdentifierName (*HIDDEN*/node_modules/@angular/compiler-cli/node_modules/@angular/tsc-wrapped/src/collector.js:241:44)
at exportedName (*HIDDEN*/node_modules/@angular/compiler-cli/node_modules/@angular/tsc-wrapped/src/collector.js:243:53)
at *HIDDEN*/node_modules/@angular/compiler-cli/node_modules/@angular/tsc-wrapped/src/collector.js:342:38
at visitNodes (*HIDDEN*/node_modules/typescript/lib/typescript.js:14809:30)
at Object.forEachChild (*HIDDEN*/node_modules/typescript/lib/typescript.js:15035:24)
at MetadataCollector.getMetadata (*HIDDEN*/node_modules/@angular/compiler-cli/node_modules/@angular/tsc-wrapped/src/collector.js:279:12)
at CompilerHost.upgradeVersion1Metadata (*HIDDEN*/node_modules/@angular/compiler-cli/src/compiler_host.js:230:46)
at CompilerHost.getMetadataFor (*HIDDEN*/node_modules/@angular/compiler-cli/src/compiler_host.js:187:30)
at StaticSymbolResolver.getModuleMetadata (*HIDDEN*/node_modules/@angular/compiler/bundles/compiler.umd.js:24456:62)
at StaticSymbolResolver._createSymbolsOf (*HIDDEN*/node_modules/@angular/compiler/bundles/compiler.umd.js:24260:46)
npm verb lifecycle APP@1.0.0~build: unsafe-perm in lifecycle true
npm verb lifecycle APP@1.0.0~build: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:*HIDDEN*/node_modules/.bin:/home/devnix/.npm-packages/bin:/home/devnix/.sdkman/candidates/gradle/current/bin:/home/devnix/Komodo-Edit-10/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/devnix/.composer/vendor/bin/:/home/devnix/bin:/usr/lib/jvm/default-java/bin:/home/devnix/Android/Sdk/platform-tools:/home/devnix/Android/Sdk/tools:/opt/gradle/gradle-4.8.1/bin
npm verb lifecycle APP@1.0.0~build: CWD: *HIDDEN*
npm info lifecycle APP@1.0.0~build: Failed to exec build script
npm verb stack Error: APP@1.0.0 build: `ionic-app-scripts build`
npm verb stack Exit status 1
npm verb stack at EventEmitter. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:304:16)
npm verb stack at emitTwo (events.js:125:13)
npm verb stack at EventEmitter.emit (events.js:213:7)
npm verb stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
npm verb stack at emitTwo (events.js:125:13)
npm verb stack at ChildProcess.emit (events.js:213:7)
npm verb stack at maybeClose (internal/child_process.js:927:16)
npm verb stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
npm verb pkgid APP@1.0.0
npm verb cwd *HIDDEN*
npm verb Linux 4.4.0-131-generic
npm verb argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build" "--prod" "--verbose"
npm verb node v8.4.0
npm verb npm v6.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! APP@1.0.0 build: `ionic-app-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the APP@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm verb exit [ 1, true ]
npm timing npm Completed in 4849ms

npm ERR! A complete log of this run can be found in:
npm ERR! /home/devnix/.npm/_logs/2018-08-07T07_12_26_031Z-debug.log
```

**My `ionic info`:**

```
Ionic:

ionic (Ionic CLI) : 4.0.5
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.1.11

Cordova:

cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 7.1.1

System:

Android SDK Tools : 26.1.1
NodeJS : v8.4.0 (/usr/local/bin/node)
npm : 6.3.0
OS : Linux 4.4

Environment:

ANDROID_HOME : /home/devnix/Android/Sdk
```

**Other Information:**

I have not problems when compiling in debug mode, I think it may be related with the AOT compilation.

Contributor guide

Open the contributing guide

Research direction

Reproduce with `npm run build --prod --verbose`, then inspect the reported failure in `@angular/tsc-wrapped/src/collector.js:241` and the related compiler-host stack frames. Compare production and debug builds to identify the triggering metadata; done means the production build no longer raises the TypeError and the behavior is verified with the affected tool versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, node.js, typescript
Domain
build-system, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.