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

Unable to build when adding angular2-logger to angular-cli managed project #113

Closed
jbruinink opened this issue Jan 16, 2017 · 20 comments
Closed

Comments

@jbruinink
Copy link

jbruinink commented Jan 16, 2017

If I build my angular-cli project which has the angular2-logger dependency, I get the following error:

jeroen@host:~/example$ ng build
Hash: b010cdf0c5268f80c482                                                               
Time: 6542ms
chunk    {0} main.bundle.js, main.bundle.map (main) 4.51 kB {2} [initial] [rendered]
chunk    {1} styles.bundle.css, styles.bundle.map, styles.bundle.map (styles) 1.77 kB {3} [initial] [rendered]
chunk    {2} vendor.bundle.js, vendor.bundle.map (vendor) 2.61 MB [initial] [rendered]
chunk    {3} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered]

ERROR in ./~/angular2-logger/app/core/logger.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
    at IdentifierObject.TokenOrIdentifierObject.getText (/home/Jeroen/example/node_modules/typescript/lib/typescript.js:53644:56)
    at /home/Jeroen/example/node_modules/@ngtools/webpack/src/loader.js:83:72
    at Array.some (native)
    at /home/Jeroen/example/node_modules/@ngtools/webpack/src/loader.js:83:32
    at Array.filter (native)
    at _removeModuleId (/home/Jeroen/example/node_modules/@ngtools/webpack/src/loader.js:82:10)
    at /home/Jeroen/example/node_modules/@ngtools/webpack/src/loader.js:167:48
 @ ./~/angular2-logger/core.js 6:9-37
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi main

ERROR in ./~/angular2-logger/app/core/providers.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
    at IdentifierObject.TokenOrIdentifierObject.getText (/home/Jeroen/example/node_modules/typescript/lib/typescript.js:53644:56)
    at /home/Jeroen/example/node_modules/@ngtools/webpack/src/loader.js:83:72
    at Array.some (native)
    at /home/Jeroen/example/node_modules/@ngtools/webpack/src/loader.js:83:32
    at Array.filter (native)
    at _removeModuleId (/home/Jeroen/example/node_modules/@ngtools/webpack/src/loader.js:82:10)
    at /home/Jeroen/example/node_modules/@ngtools/webpack/src/loader.js:167:48
 @ ./~/angular2-logger/core.js 7:9-40
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi main

The error can be reproduced by doing the following:

npm install -g angular-cli
ng new example
cd example
npm install -save angular2-logger

Then edit the src/app/app.module.ts and add the import:

import { Logger } from 'angular2-logger/core';

and add the provider:

  providers: [Logger],
@Till86
Copy link

Till86 commented Jan 16, 2017

Same issue for our project

@Zeemee7
Copy link

Zeemee7 commented Jan 16, 2017

Same for me, it happened with the update of angular-cli 1.0.0-beta-24 to 1.0.0-beta-25.5. It worked with beta-24.

@jbruinink
Copy link
Author

jbruinink commented Jan 16, 2017

I tried downgrading to angular-cli 1.0.0-beta.24 and I get the same error.

sudo npm uninstall -g angular-cli
sudo npm install -g angular-cli@1.0.0-beta.24
ng new example
cd example
npm install -save angular2-logger
[edit app.module.ts]
ng build

@k1ng440
Copy link

k1ng440 commented Jan 16, 2017

we have the issue. please fix

@rodneyjoyce
Copy link

Was working fine with AngularCLI Beta .21. Upgraded to .25.5 and this error occurs.

Interestingly, I see that the core team have implemented a logger in 25.5 CLI : angular/angular-cli@e3b48da

@eservent
Copy link

I have the same issue (worked with beta 24) and I found a way to avoid the problem.
I replace this import :
import {Logger, Options as LoggerOptions, Level as LoggerLevel} from 'angular2-logger/core';
By these imports :
import {Level as LoggerLevel} from 'angular2-logger/app/core/level';
import {Logger, Options as LoggerOptions} from 'angular2-logger/app/core/logger';

@langley-agm
Copy link
Contributor

Hello all,

Really sorry you are all running into these issues but I won't be making any changes based of a beta product, when you use a beta software you are bound to have issues eventually and things will be changing, I can't fix it everytime they brake something.

If someone has a pull request with the fix I don't mind taking a look at it.

@rodneyjoyce
Copy link

Fair enough - good point

@rodneyjoyce
Copy link

The fix by @eservent seems to work for me too - thx

@bruderol
Copy link

workaround by @eservent is working - but it is annoying to have to adjust all the imports all the times, because the IDE will not use that import automatically (at least intelliJ doesnt). I think it is bad that they broke that in the CLI - maybe we should file it as a bug there?

@langley-agm
Copy link
Contributor

@bruderol certainly worth a try.

@bruderol
Copy link

So could please someone open a bug at Angular-CLI, who has some more insight into the details of this? Thanks!

@chunghha
Copy link

Probably this already fixed in Angular-cli, angular/angular-cli@e91552f

So might wait for next release of the cli or if you are like me then I found an alternative logger for AOT support here.
https://github.com/noemi-salaun/ng2-logger

@langley-agm I hope you wouldn't mind another logger linked here. Just info for others.

@langley-agm
Copy link
Contributor

@chunghha not a problem !

@Lyoko-Jeremie
Copy link

i have the same problem in @angular/cli 1.0.0-beta.30 with AOT build.

@cloudlena
Copy link

cloudlena commented Feb 28, 2017

It might help that the problem doesn't occur if I have just a single

import { Logger } from 'angular2-logger/app/core/logger';

in my code. All other import statements can use from 'angular2-logger/core' directly and it still works.

@langley-agm, since the Angular-CLI is now out of beta and this problem still occurs, it might be worth looking into it. The proposed workaround doesn't do it for my anymore because with it, ng lint complains about linting issues inside .../my-project/node_modules/angular2-logger/app/core/logger.ts (using @angular/cli@1.0.0).

Furthermore, it might be helpful to look into angular/angular-cli#4072 (comment) where a seemingly similar issue is discussed.

@elendil-software
Copy link

I have the same problem using @angular/cli 1.0.0-rc.1

ERROR in ./~/angular2-logger/app/core/logger.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
    at Object.getTokenPosOfNode (D:\Projects\WebProjects\AngularProject\node_modules\typescript\lib\typescript.js:6768:71)
    at IdentifierObject.TokenOrIdentifierObject.getStart (D:\Projects\WebProjects\AngularProject\node_modules\typescript\lib\typescript.js:80500:23)
    at IdentifierObject.TokenOrIdentifierObject.getText (D:\Projects\WebProjects\AngularProject\node_modules\typescript\lib\typescript.js:80521:77)
    at refactor.findAstNodes.filter (D:\Projects\WebProjects\AngularProject\node_modules\@ngtools\webpack\src\loader.js:139:44)
    at Array.filter (native)
    at refactor.findAstNodes.forEach.node (D:\Projects\WebProjects\AngularProject\node_modules\@ngtools\webpack\src\loader.js:138:14)
    at Array.forEach (native)
    at _removeDecorators (D:\Projects\WebProjects\AngularProject\node_modules\@ngtools\webpack\src\loader.js:129:10)
    at Promise.resolve.then (D:\Projects\WebProjects\AngularProject\node_modules\@ngtools\webpack\src\loader.js:292:33)
 @ ./~/angular2-logger/core.js 6:9-37
 @ ./src/$$_gendir/app/app.module.ngfactory.ts
 @ ./src/main.ts
 @ multi ./src/main.ts

@wkit23
Copy link

wkit23 commented Mar 23, 2017

@mastertinner workaround worked with @angular/cli 1.0.0-rc.1 & 2.

@kunleawotunbo
Copy link

@mastertinner This worked for me too. Many thanks.

@langley-agm
Copy link
Contributor

Closing this, for follow up you can use #79

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