angular-cli: in 1.0.0-beta.24 getting ERROR in Error encountered resolving symbol values statically

OS?

Windows 10 64

Versions.

latest ng 2.4.1 and cli 1.0.0-beta.24

Repro steps.

Angular 2 Kitchen sink: http://ng2.javascriptninja.io and source@ https://github.com/born2net/Angular-kitchen-sink

ERROR in Error encountered resolving symbol values statically. Calling function 'MsLibModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in C:/msweb/Angular-kitchen-sink/src/app/app.module.ts, resolving symbol AppModule in C:/msweb/Angular-kitchen-sink/src/app/app.module.ts
webpack: bundle is now VALID.

I am loading a module with forRoot as in:

    imports: [
      ...
        MsLibModule.forRoot(),
      ...
    ],

which doens’t do much,

export class MsLibModule {
    static forRoot(): ModuleWithProviders {
        return {
            ngModule: MsLibModule,
            providers: []
        };
    }
}

as you can see no lambada needed… and still getting the error of:


ERROR in Error encountered resolving symbol values statically. Calling function 'MsLibModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in C:/msweb/Angular-kitchen-sink/src/app/app.module.ts, resolving symbol AppModule in C:/msweb/Angular-kitchen-sink/src/app/app.module.ts

regards

Sean

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 8
  • Comments: 44 (6 by maintainers)

Most upvoted comments

@angular/cli 1.0.0-rc.0 still has same problem. 3 months passed and still we can’t use newest AOT to compile our projects that use forRoot static method to provide providers for root module. 😦

any progress about this issue, we have the same problem.

Same here.

angular-cli: 1.0.0-beta.24
node: 7.2.0
os: darwin x64

Steps to reproduce:

  1. ng new test-app
  2. Create foo.service.ts in src/app with content:
import { Injectable } from '@angular/core';
import { EventEmitter } from 'events';

@Injectable()
export class FooService extends EventEmitter  {

}
  1. Add the service to providers in app.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';

import { FooService } from './foo.service';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule
  ],
  providers: [
    FooService
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
  1. Build the app: ng build --prod --aot. The output is:
ERROR in Error encountered resolving symbol values statically. Could not resolve events relative to /Users/user/path/test-app/src/app/foo.service.ts., resolving symbol FooService in /Users/user/path/test-app/src/app/foo.service.ts

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/user/path/test-app/src'
 @ ./src/main.ts 4:0-74
 @ multi main

ERROR in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
Module not found: Error: Can't resolve '/Users/user/path/test-app/src/$$_gendir' in '/Users/user/path/test-app/node_modules/@angular/core/src/linker'
 @ ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js 69:15-36 85:15-102
 @ ./~/@angular/core/src/linker.js
 @ ./~/@angular/core/src/core.js
 @ ./~/@angular/core/index.js
 @ ./src/main.ts
 @ multi main

For some reason the EventEmitter breaks the build. The following code compiles with angular 2.2.3, angular-cli 1.0.0-beta.22-1 and add the @ngtools/webpack@1.1.9 as dependency in package.json.

Reverting to 1.0.0-beta.19-3 like @alvachien mentioned fixes the issue for me. I also experimented with working backwards through versions and the first version that did not break ng build for me is 1.0.0-beta.21.

just to add my error into the mix:

ERROR in Error encountered resolving symbol values statically. Could not resolve events relative to /Users/…/node_modules/@types/mongodb/index.d.ts., resolving symbol Db in Users/…/node_modules/@types/mongodb/index.d.ts

Why is it going into mongodb when nothing in my client side code refs that module?