Skip to content

ng build --prod fails in beta 1.0.0-beta.32.3 #4918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jimdubbs opened this issue Feb 22, 2017 · 6 comments
Closed

ng build --prod fails in beta 1.0.0-beta.32.3 #4918

jimdubbs opened this issue Feb 22, 2017 · 6 comments
Labels
needs: repro steps We cannot reproduce the issue with the information given

Comments

@jimdubbs
Copy link

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
Mac OSX El Capitan

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:
@angular/cli: 1.0.0-beta.32.3
node: 6.9.4
os: darwin x64
@angular/common: 2.4.8
@angular/compiler: 2.4.8
@angular/core: 2.4.8
@angular/flex-layout: 2.0.0-beta.5
@angular/forms: 2.4.8
@angular/http: 2.4.8
@angular/material: 2.0.0-beta.2
@angular/platform-browser: 2.4.8
@angular/platform-browser-dynamic: 2.4.8
@angular/router: 3.4.8
@angular/cli: 1.0.0-beta.32.3
@angular/compiler-cli: 2.4.8

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.
Was created with older version of CLI. Followed upgrade process.

The log given by the failure.

Normally this include a stack trace and some more information.

ERROR in ../x-shared/services/auth.service.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
    at Object.getTokenPosOfNode (/Users/jimmywestcott/Documents/github/QMonitor/web/node_modules/typescript/lib/typescript.js:5692:71)
    at IdentifierObject.TokenOrIdentifierObject.getStart (/Users/jimmywestcott/Documents/github/QMonitor/web/node_modules/typescript/lib/typescript.js:53623:23)
    at IdentifierObject.TokenOrIdentifierObject.getText (/Users/jimmywestcott/Documents/github/QMonitor/web/node_modules/typescript/lib/typescript.js:53644:77)
    at refactor.findAstNodes.filter (/Users/jimmywestcott/Documents/github/QMonitor/web/node_modules/@ngtools/webpack/src/loader.js:138:44)
    at Array.filter (native)
    at refactor.findAstNodes.forEach.node (/Users/jimmywestcott/Documents/github/QMonitor/web/node_modules/@ngtools/webpack/src/loader.js:137:14)
    at Array.forEach (native)
    at _removeDecorators (/Users/jimmywestcott/Documents/github/QMonitor/web/node_modules/@ngtools/webpack/src/loader.js:128:10)
    at Promise.resolve.then (/Users/jimmywestcott/Documents/github/QMonitor/web/node_modules/@ngtools/webpack/src/loader.js:304:33)
 @ ./src/$$_gendir/app/app.module.ngfactory.ts 101:0-65
 @ ./src/main.ts
 @ multi ./src/main.ts

Mention any other details that might be useful.

ng build works fine, ng build --prod throws this error on each of my services that has an @Injectable() decorator. the services that do not have @Injectable() do not throw this error. I've tried blowing away node_modules and several different versions of CLI etc, but with no luck. Package JSON below:

"dependencies": {
    "@angular/common": "^2.4.0",
    "@angular/compiler": "^2.4.0",
    "@angular/core": "^2.4.0",
    "@angular/flex-layout": "^2.0.0-beta.5",
    "@angular/forms": "^2.4.0",
    "@angular/http": "^2.4.0",
    "@angular/material": "^2.0.0-beta.2",
    "@angular/platform-browser": "^2.4.0",
    "@angular/platform-browser-dynamic": "^2.4.0",
    "@angular/router": "^3.4.0",
    "angular-2-local-storage": "^1.0.1",
    "angular2-moment": "^1.1.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.0.1",
    "socket.io-client": "^1.7.3",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.6"
  },
  "devDependencies": {
    "@angular/cli": "^1.0.0-beta.32.3",
    "@angular/compiler-cli": "^2.4.0",
    "@types/jasmine": "^2.5.38",
    "@types/node": "^6.0.60",
    "codelyzer": "~2.0.0-beta.4",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-remap-istanbul": "^0.2.0",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.4.2",
    "typescript": "~2.0.0",
    "webdriver-manager": "10.2.5"
  }

Thanks! We'll be in touch soon.

@krotscheck
Copy link

krotscheck commented Feb 24, 2017

I can verify this, and add more information:

First- it appears that this may be related to the issue identified by @EMorales in #4072.

Secondly - we (vmware) can verify that if a shared library packages the source typescript alongside the d.ts, js, and metadata files, the compiler will throw this error:

ERROR in ./~/shared-lib/lib/index.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
    at Object.getTokenPosOfNode (..../ui-project/node_modules/typescript/lib/typescript.js:5692:71)
    at IdentifierObject.TokenOrIdentifierObject.getStart (..../ui-project/node_modules/typescript/lib/typescript.js:53623:23)
    at IdentifierObject.TokenOrIdentifierObject.getText (..../ui-project/node_modules/typescript/lib/typescript.js:53644:77)
    at refactor.findAstNodes.filter (..../ui-project/node_modules/@ngtools/webpack/src/loader.js:135:44)
    at Array.filter (native)
    at refactor.findAstNodes.forEach.node (..../ui-project/node_modules/@ngtools/webpack/src/loader.js:134:14)
    at Array.forEach (native)
    at _removeDecorators (..../ui-project/node_modules/@ngtools/webpack/src/loader.js:125:10)
    at Promise.resolve.then (..../ui-project/node_modules/@ngtools/webpack/src/loader.js:295:33)
 @ ./src/$$_gendir/app/app.module.ngfactory.ts 27:0-55
 @ ./src/main.ts
 @ multi ./src/main.ts

Is there any benefit to packaging *.ts files alongside compiled sources? My assumption is that map files will be honored, but if that's not the case there's no real reason for us to include those.

@weo3dev
Copy link

weo3dev commented Feb 27, 2017

Taking out the .ts files in the src folder of the 3rd party's package, per the instructions given by @emorales here, is what cleared all various issues to build --prod for me.

@filipesilva
Copy link
Contributor

Libraries shouldn't ship their TS files, but the CLI shouldn't just die if they happen to be there either.

Can you get me a repro so we can investigate?

@filipesilva filipesilva added the needs: repro steps We cannot reproduce the issue with the information given label Mar 13, 2017
@weo3dev
Copy link

weo3dev commented Mar 13, 2017

Hey @filipesilva, are you directing that to anyone in particular? I used -cli and one 3rd party item, ng2-nouislider that I took the ts file out from, and have been using it for my own personal site. Public repo is here, if you need it.

Please be advised: at the moment, I don't have nouislider in affect, because I am in the middle of investigating an unrelated issue for production with it.

@filipesilva
Copy link
Contributor

Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version.

If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: repro steps We cannot reproduce the issue with the information given
Projects
None yet
Development

No branches or pull requests

4 participants