@ngtools/webpack - Error encountered resolving symbol values statically
Versions.
Repro steps.
Not really repro steps, but the not-changed webpack config used to work with [email protected] and @ngtools/[email protected], since upgrading I get the error described below and I have no idea what to do about it.
The log given by the failure.
ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AnimationDriver in /Users/ajantsch/Dropbox/Projects/22_9Cookies/transmission-web-client/webkick/node_modules/@angular/platform-browser/src/dom/animation_driver.d.ts, resolving symbol BrowserTestingModule in /Users/ajantsch/Dropbox/Projects/22_9Cookies/transmission-web-client/webkick/node_modules/@angular/platform-browser/testing/browser.d.ts, resolving symbol BrowserTestingModule in /Users/ajantsch/Dropbox/Projects/22_9Cookies/transmission-web-client/webkick/node_modules/@angular/platform-browser/testing/browser.d.ts
ERROR in ./src/bootstrap.ts
Module not found: Error: Can't resolve './../$$_gendir/src/app/main.module.ngfactory' in '/Users/ajantsch/Dropbox/Projects/22_9Cookies/transmission-web-client/webkick/src'
@ ./src/bootstrap.ts 3:0-83
ERROR in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
Module not found: Error: Can't resolve '/Users/ajantsch/Dropbox/Projects/22_9Cookies/transmission-web-client/webkick/$$_gendir' in '/Users/ajantsch/Dropbox/Projects/22_9Cookies/transmission-web-client/webkick/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/bootstrap.ts
Same problem. So?
This issue looks to be a duplicate of https://github.com/angular/angular-cli/issues/3707
I'm getting a similar error:
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '[...]/src'
@ ./src/main.ts 4:0-74
@ multi ./src/main.ts
I get the same error:
ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '...' @ ./src/main.ts 4:0-74 @ multi ./src/main.ts
Please, someone help us.
As many, I was exposed after an ugrade to the message
ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function,.....
My cause was in the reducers, who worked perfectly with 2.3
The solution was to replace
export const myReducer: ActionReducer<string> = function(state: string = "pipo", action: Action){
by
export function myReducer(state: string = "pipo", action: Action){
I hope it help getting from the hole I was stuck in for quite a few hours...
Alex
Testing it out a bit with ng2-toastr with
@angular/cli: 1.0.0-beta.31
node: 7.5.0
os: darwin x64
@angular/common: 2.4.7
@angular/compiler: 2.4.7
@angular/core: 2.4.7
@angular/forms: 2.4.7
@angular/http: 2.4.7
@angular/platform-browser: 2.4.7
@angular/platform-browser-dynamic: 2.4.7
@angular/router: 3.4.7
@angular/cli: 1.0.0-beta.31
@angular/compiler-cli: 2.4.7
And consider following import provided in app.module.ts for all examples below:
import { ToastModule, ToastOptions } from 'ng2-toastr/ng2-toastr';
The following does not work (resulting in the error further down):
Case 1
export const globalToastOptions: ToastOptions = new ToastOptions({
animate: 'flyRight',
positionClass: 'toast-bottom-right'
});
@NgModule({
imports: [
ToastModule.forRoot(globalToastOptions)
],
...
})
Case 2
export function globalToastOptions() {
return new ToastOptions({
animate: 'flyRight',
positionClass: 'toast-bottom-right'
});
}
@NgModule({
imports: [
ToastModule.forRoot(globalToastOptions())
],
...
})
Case 3
@NgModule({
imports: [
ToastModule.forRoot(new ToastOptions({
animate: 'flyRight',
positionClass: 'toast-bottom-right'
}))
],
...
})
Error
ng build output:
ERROR in Error encountered resolving symbol values statically. Calling function 'ToastOptions', function calls are not supported. Consider replacing the function or lambda
with a reference to an exported function, resolving symbol globalToastOptions in /WebApp/src/app/app.module.ts, resolving symbol AppModule in /WebApp/src/app/app
.module.ts, resolving symbol AppModule in /WebApp/src/app/app.module.ts, resolving symbol AppModule in /WebApp/src/app/app.module.ts
However, the following does work:
Case 4
@NgModule({
imports: [
ToastModule.forRoot()
],
...
})
Case 5
@NgModule({
imports: [
ToastModule.forRoot({
animate: 'flyRight',
positionClass: 'toast-bottom-right'
})
],
...
})
In my case this solves the issue for ng2-toastr, but I still have problems with angular2-highcharts and a suggested workaround doesn't quite cut it for my implementation.
It would be nice if someone on the angular team could dive into what's causing this. At least use a warning instead of error.
ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in /Users/Test-PRJ/PRJ/AJ/Projects/Test/Test-Source/src/app/app.module.ts, resolving symbol AppModule in /Users/Test-PRJ/PRJ/AJ/Projects/Test/Test-Source/src/app/app.module.ts
Stuck with this issue, Now i cant run the project as well as build
WARNING in ./~/@angular/router/src/router_module.js 303:51-71 "export 'LOCATION_INITIALIZED' was not found in '@angular/common' webpack: Compiled with warnings.
We were able to solve our ./../$$_gendir/src/app/main.module.ngfactory by ensuring we removed all modules/files that weren't being used.
angular.cli 1.0.0-beta33 and angular 2.4.1
I had this error when in appModule was
{
path: "work",
loadChildren: "/modules/social/work/WorkModule#WorkModule"
}
I have this issue
@deot can reply, your full tsconfig.json file. I tried to add your lines but nothing change.
This is preventing production deploys, isn't it?
Please make sure you delete your project dependencies of the old angular-cli in your package.json using:
npm uninstall --save angular-cli
An issue was having the same error as stated above and I found this to be the solution, might be helpful for someone else.
I fixed this issue by removing all function calls from my static forRoot() functions. I replaced those functions with factory functions declared/referenced by the provider instead.
So in @marioleed's cases that didn't work (1-3) you can see that functions were called during configuration, whereas on the others they are objects using the Typescript Class as an Interface.
There's probably a good reason for not allowing arbitrary functions to be called at the configuration stage, but I'm too new to Angular to comment on exactly why.
Any solution ?
Keep getting this error with ng serve:
ERROR in this.symbolResolver.getSymbolByModule is not a function
with angular and angular/cli latest version. Since my project relies on primeng ultima template, I'm Trying to keep my project as close as possible to ultima demo project, which compiles correctly whereas mine doesn't.
Ant solution for this. Im facing this issue.