Skip to content
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

Aot typeerror #59

Closed
Anuovec opened this issue Feb 6, 2017 · 18 comments
Closed

Aot typeerror #59

Anuovec opened this issue Feb 6, 2017 · 18 comments

Comments

@Anuovec
Copy link

Anuovec commented Feb 6, 2017

Version: 1.5.0
Angular2 version 2.4.5 as well as 2.4.6
Angular cli version 1.0.0-beta.30 as well as 1.0.0-beta.26

During aot serve I get this error.
Any ideas?

ERROR in ./~/ng2-nouislider/src/nouislider.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
    at Object.getTokenPosOfNode (/Users/tibinko/Documents/work/mates/frontend2/migration-project/node_modules/typescript/lib/typescript.js:5687:71)
    at IdentifierObject.TokenOrIdentifierObject.getStart (/Users/tibinko/Documents/work/mates/frontend2/migration-project/node_modules/typescript/lib/typescript.js:53619:23)
    at IdentifierObject.TokenOrIdentifierObject.getText (/Users/tibinko/Documents/work/mates/frontend2/migration-project/node_modules/typescript/lib/typescript.js:53640:77)
    at /Users/tibinko/Documents/work/mates/frontend2/migration-project/node_modules/@ngtools/webpack/src/loader.js:119:42
    at Array.filter (native)
    at /Users/tibinko/Documents/work/mates/frontend2/migration-project/node_modules/@ngtools/webpack/src/loader.js:118:14
    at Array.forEach (native)
    at _removeDecorators (/Users/tibinko/Documents/work/mates/frontend2/migration-project/node_modules/@ngtools/webpack/src/loader.js:109:10)
    at /Users/tibinko/Documents/work/mates/frontend2/migration-project/node_modules/@ngtools/webpack/src/loader.js:282:48
 @ ./src/$$_gendir/app/modules/app.module.ngfactory.ts 42:0-58
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts
@rerickson1
Copy link

I see the same issue

@kkotak
Copy link

kkotak commented Feb 8, 2017

Same here. +1

@kkotak
Copy link

kkotak commented Feb 8, 2017

Adding "@ngtools/webpack": "1.2.3" to package.json resolved this issue for me.

@tb tb closed this as completed Feb 9, 2017
@rerickson1
Copy link

rerickson1 commented Feb 9, 2017

I can confirm

Adding "@ngtools/webpack": "1.2.3" to package.json resolved this issue for me.

I don't think this issue should be closed though. We shouldn't have to add this to our package.json. The dependencies for this package (ng2-nouislider) should be setup correctly to solve this issue.

@tb tb reopened this Feb 9, 2017
@stephanrauh
Copy link

Same here. +1

@stephanrauh
Copy link

@tb Maybe the discussion in this tickets helps you to solve bug bug. Among other things, it mentions what causes this (or a similar) bug: angular/angular-cli#4072

@rsquared24
Copy link

@rerickson1 @kkotak did you add @ngtools/webpack as a dev dependency? It still throws the same error for me :(

@angular/cli@1.0.0-beta.32.3
@ngtools/webpack@1.2.3
ng2-nouislider@1.5.1

@kkotak
Copy link

kkotak commented Feb 21, 2017

@rsquared-digital, Yes I have under dev. I also have "@angular/cli": "1.0.0-beta.30", which might also be relevant.

@rerickson1
Copy link

@rsquared-digital I have it under dev as well. Here is my package.json content:
"dependencies": {
"@angular/common": "2.4.3",
"@angular/compiler": "2.4.3",
"@angular/core": "2.4.3",
"@angular/forms": "2.4.3",
"@angular/http": "2.4.3",
"@angular/platform-browser": "2.4.3",
"@angular/platform-browser-dynamic": "2.4.3",
"@angular/router": "3.4.3",
"angular-in-memory-web-api": "^0.2.4",
"angular2-jwt": "^0.1.27",
"angular2-ui-switch": "^1.2.0",
"bootstrap": "~3.3.7",
"core-js": "^2.4.1",
"jquery": "~3.1.1",
"jsen": "^0.6.4",
"jsrsasign": "^6.2.3",
"ng2-bootstrap": "^1.3.1",
"ng2-nouislider": "^1.5.0",
"nouislider": "^9.2.0",
"rxjs": "^5.0.1",
"ts-helpers": "^1.1.1",
"zone.js": "^0.7.2"
},
"devDependencies": {
"@angular/cli": "1.0.0-beta.30",
"@angular/compiler-cli": "2.4.3",
"@ngtools/webpack": "1.2.3",
"@types/jasmine": "2.5.38",
"@types/jsen": "0.0.18",
"@types/node": "^6.0.42",
"codelyzer": "~2.0.0-beta.1",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "~4.0.13",
"ts-node": "1.2.1",
"tslint": "^4.3.0",
"typescript": "~2.0.3"
}

@kkotak
Copy link

kkotak commented Feb 21, 2017

Check your typescript version. Mine is 2.1.5. Other than that, I'm not sure.

@sabrio
Copy link

sabrio commented Feb 26, 2017

I am having the same issue while building my project in production mode ng build --prod and after removing the ng2-nouislider everything works fine.
Typescript: 2.1.6 or 2.2.1
@angular/cli: 1.0.0-rc.0
@ngtools/webpack: 1.2.5 or 1.2.11

Any work around please, I need to deploy production version??

@weo3dev
Copy link

weo3dev commented Feb 27, 2017

Can confirm. Am getting same error with simple ng build --prod. Error specifically points to ng2-nouislider's ts.

ERROR in ./~/ng2-nouislider/src/nouislider.ts
Module build failed: TypeError: Cannot read property 'text' of undefined

I'm digging into it right now, and I will add my two cents' worth that yes, when releasing, either things like this should be clarified in the instructions on a readme, or should be resolved within the package itself. I recognize that the landscape is still changing rapidly these days, but it is worth it to communicate upfront that a little housekeeping may be necessary to get a particular directive to work in any one person's production environment.

I will post any updates if I find a working case that isn't a hack.

@stephanrauh
Copy link

A radical workaround is to use replace the library by the file https://github.com/tb/ng2-nouislider/blob/master/src/nouislider.ts. Just copy it somewhere in your source folder and remove the library from the packages.json until the bug has been fixed.

@sabrio
Copy link

sabrio commented Feb 27, 2017

@stephanrauh thanks, it works. Confirmed

@weo3dev
Copy link

weo3dev commented Feb 27, 2017

SOLVED

Per @emoralesb05 in this conversation, which is a closed, open again conversation, what seems to be the issue are source ts files being included in the delivered package, thereby tripping up the build script(s) of angular-cli.

I literally went into

node_modules/ng2-nouislider/src/

and removed

nouislider.ts

I am now able to:

npm build --prod
npm build --prod --aot

My current setup is the following:

@angular/cli: 1.0.0-rc.0
node: 7.4.0
os: darwin x64
@angular/common: 2.4.8
@angular/compiler: 2.4.8
@angular/core: 2.4.8
@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-rc.0
@angular/compiler-cli: 2.4.8

I upgraded my build following the Upgrade Steps from the Angular-CLI team, listed here.

I do not apparently have any reason to cut/paste a reference to @ngtools/webpack in package.json, as listed here.

Here are my dependencies and dev dependencies, for anyone's reference:

  "dependencies": {
    "@angular/common": "^2.4.8",
    "@angular/compiler": "^2.4.8",
    "@angular/core": "^2.4.8",
    "@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",
    "core-js": "^2.4.1",
    "ng2-nouislider": "^1.5.1",
    "nouislider": "^9.2.0",
    "rxjs": "^5.2.0",
    "zone.js": "^0.7.7"
  },
  "devDependencies": {
    "@angular/cli": "^1.0.0-rc.0",
    "@angular/compiler-cli": "^2.4.8",
    "@types/jasmine": "2.5.43",
    "@types/node": "~7.0.5",
    "codelyzer": "~3.0.0-beta.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.5.0",
    "karma-chrome-launcher": "~2.0.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^0.2.3",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.1",
    "ts-node": "~2.1.0",
    "tslint": "~4.4.2",
    "typescript": "~2.2.1"
  }

And in the app itself, I only use the following -
app.module.ts

import { NouisliderModule } from 'ng2-nouislider';
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    ReactiveFormsModule,
    NouisliderModule,
    MaterialModule.forRoot(),
    RouterModule.forRoot(ROUTES)
  ],

I use the ui slider in a child component, with no other import code being needed.

I truly hope this helps everyone get back on track.

@tb
Copy link
Owner

tb commented Feb 27, 2017

@MetaVurt Thanks! I published that change as 1.5.2 see 8f03307

@bradrisse
Copy link

I can confirm --prod build is now working. Thanks!

@weo3dev
Copy link

weo3dev commented Feb 27, 2017

Rock n roll, @tb, glad to be of help!

@tb tb closed this as completed Feb 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants