Angular-cli: Build error when adding LOG_LOGGER_PROVIDERS from angular2-logger

Created on 1 Feb 2017  路  4Comments  路  Source: angular/angular-cli

OS?

Ubuntu precise (12.04.5 LTS)

Versions.

angular-cli: 1.0.0-beta.26
node: 6.9.2
os: linux x64
@angular/common: 2.4.5
@angular/compiler: 2.4.5
@angular/core: 2.4.5
@angular/forms: 2.4.5
@angular/http: 2.4.5
@angular/platform-browser: 2.4.5
@angular/platform-browser-dynamic: 2.4.5
@angular/router: 3.4.5
@angular/compiler-cli: 2.4.5
[email protected]

Repro steps.

$ ng new testapp
$ cd testapp/
$ npm install angular2-logger --save
$ cd src/app
$ patch -p0 <<-EOF

diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 67ae491..34ef2fa 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -4,6 +4,7 @@ import { FormsModule } from '@angular/forms';
 import { HttpModule } from '@angular/http';

 import { AppComponent } from './app.component';
+import { LOG_LOGGER_PROVIDERS } from "angular2-logger/core";

 @NgModule({
   declarations: [
@@ -14,7 +15,7 @@ import { AppComponent } from './app.component';
     FormsModule,
     HttpModule
   ],
-  providers: [],
+  providers: [LOG_LOGGER_PROVIDERS],
   bootstrap: [AppComponent]
 })
 export class AppModule { }
EOF

$ ng build

The log given by the failure.

ERROR in Error encountered resolving symbol values statically. Only initialized variables and constants can be referenced because the value of this variable is needed by the template compiler (position 48:14 in the original .ts file), resolving symbol LOG_LOGGER_PROVIDERS in /home/user/testapp/node_modules/angular2-logger/core.d.ts, resolving symbol AppModule in /home/user/testapp/src/app/app.module.ts, resolving symbol AppModule in /home/user/testapp/src/app/app.module.ts

Mention any other details that might be useful.

  • Not sure if the issue is with Typescript, or angular-cli, or webpack, or angular2-logger...
  • I have seen other similar case here.
  • I will be working on a workaround.

Most helpful comment

That works, but the exact line is
import { LOG_LOGGER_PROVIDERS } from "angular2-logger/app/core/providers";

Many thanks! This ticket can be closed if unrelated to angular-cli.

All 4 comments

There's a known issue with Angular compiler and export * from ..., which is how LOG_LOGGER_PROVIDERS is exported from "angular2-logger/core".

For a workaround, try importing from "angular2-logger/core/providers" instead, as it seems declared there.

That works, but the exact line is
import { LOG_LOGGER_PROVIDERS } from "angular2-logger/app/core/providers";

Many thanks! This ticket can be closed if unrelated to angular-cli.

I've followed the steps above and i'm still getting an error. I'm using beta 31 of angular-cli.

undefined is not an object (evaluating '_this.logger.info')

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._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sysmat picture sysmat  路  3Comments

jmurphzyo picture jmurphzyo  路  3Comments

naveedahmed1 picture naveedahmed1  路  3Comments

rajjejosefsson picture rajjejosefsson  路  3Comments

hartjo picture hartjo  路  3Comments