angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ERROR in Error encountered resolving symbol values statically. Calling function 'PerfectScrollbarModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function

Open Oleg1969 opened this issue 9 years ago • 98 comments

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?) Mac OSX

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here: cli beta 24

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.

  1. generate new project with cli beta 24
  2. npm install angular2-perfect-scrollbar --save
  3. import PerfectScrollbarModule.forRoot({suppressScrollX: true})

The log given by the failure.

Normally this include a stack trace and some more information.

ERROR in Error encountered resolving symbol values statically. Calling function 'PerfectScrollbarModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in /.../app.module.ts, resolving symbol AppModule in /..../src/app/app.module.ts

Mention any other details that might be useful.

angular version 2.3.1


Thanks! We'll be in touch soon.

Oleg1969 avatar Dec 22 '16 16:12 Oleg1969

@Aides359 It's better to use this approach for dynamic loading modules with AOT: Lazy loading module

// [...]

export const routes: any = [
  { path: '', redirectTo: '/dashboard', pathMatch: 'full' },
    {
       [
          {
             path: 'dashboard',
             loadChildren: 'YOUR_PATH/dashboard.module#DashboardModule',
          },
// [...]

eronalves avatar Jun 26 '17 16:06 eronalves

I get this error because I building the ready to AOT the problem is that AOT doesn't support arrow functions. For more info please check it here https://github.com/rangle/angular-2-aot-sandbox#current-status

rozzs74 avatar Jul 02 '17 08:07 rozzs74

Had the same problem and @eronalves answer solved it.

emanuelvircaimprezzio avatar Jul 03 '17 13:07 emanuelvircaimprezzio

have same problem

ERROR in Error encountered resolving symbol values statically. Calling function 'makeDecorator', function 
calls are not supported. Consider replacing the function or lambda with a reference to an exported 
function, resolving symbol Injectable in D:/PROJECTS/O4P/node_modules/ng2-socket-
io/node_modules/@angular/core/src/di/metadata.d.ts, resolving symbol OpaqueToken in 
D:/PROJECTS/O4P/node_modules/ng2-socket-io/node_modules/@angular/core/src/di/opaque_token.d.ts, 
resolving symbol OpaqueToken in D:/PROJECTS/O4P/node_modules/ng2-socket-
io/node_modules/@angular/core/src/di/opaque_token.d.ts

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'D:\PROJECTS\O4P\src'
@ ./src/main.ts 5:0-74
@ multi ./src/main.ts

di3orlive avatar Jul 05 '17 16:07 di3orlive

Related AOT build issue here:

ERROR in Error encountered resolving symbol values statically. Calling function 'NoOpAnim
ationDriver', function calls are not supported. Consider replacing the function or lambda
with a reference to an exported function, resolving symbol AnimationDriver.NOOP in /User
s/maximilianosuster/Development/angular-agentsection/node_modules/@angular/platform-brows
er/src/dom/animation_driver.d.ts, resolving symbol BrowserTestingModule in /Users/maximil
ianosuster/Development/angular-agentsection/node_modules/@angular/platform-browser/testin
g/browser.d.ts, resolving symbol BrowserTestingModule in /Users/maximilianosuster/Develop
ment/angular-agentsection/node_modules/@angular/platform-browser/testing/browser.d.ts

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/
maximilianosuster/Development/angular-agentsection/src'
 @ ./src/main.ts 4:0-74
 @ multi ./src/main.ts
➜  angular-agentsection git:(109-renable-unit-tests) ✗

I have seen reports on issues with AOT and NoOpAnimationDriver but previously proposed solutions do not work for me. Anyone has any idea where this error originates?

maxruby avatar Jul 05 '17 22:07 maxruby

Fixed by deleting @angular folder at internal node_modules directory of a problematic module (ng2-color-picker in my case).

x1unix avatar Jul 17 '17 05:07 x1unix

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 (position 69:19 in the original .ts file), resolving symbol AppModule in app.module.ts

AABRHALEY avatar Jul 23 '17 17:07 AABRHALEY

Can any one help me to fix this problem in my code??? this is the error 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 (position 69:19 in the original .ts file), resolving symbol AppModule in src/app/app.module.ts webpack: Failed to compile.

AABRHALEY avatar Jul 23 '17 17:07 AABRHALEY

@Abrhaley1 you should provide at least some of the corresponding code so we can suggest you modifications. Also I'm sure if you check some of the previous suggestions and solutions in this thread you will find some guidelines and solutions that might solve your problem.

metodribic avatar Jul 24 '17 08:07 metodribic

it woooooooooorks ^^ just I add "paths": { "@angular/": ["../node_modules/@angular/"] } in tsconfig and bilth with ng build --prod --aot=false hhh I'm happy <3

SarraMrbt avatar Jul 27 '17 13:07 SarraMrbt

What I did to fix this issue was not using lambda in the function I was passing as parameter for useFactory. I used function(){ return new Config() } instead of () => new Config() and it worked.

umagon avatar Aug 09 '17 13:08 umagon

This issue should be locked for any further discussion because we figure it out, that the issue is current limitations of AOT and that we should follow the guidelines in order to make code AOT compatible. There is bunch of good articles/solutions mentioned in this thread so listing the known solutions on and on is not productive and does not help anyone.

cc: @Oleg1969

metodribic avatar Aug 10 '17 12:08 metodribic

@metodribic Why do I have this problem when using ng serve if it's a problem with AoT?

umagon avatar Aug 10 '17 14:08 umagon

Sorry I ment Angular CLI instead of AOT. But actually all of this problems are related to AOT somehow, since AOT compatible code resolves the issue...

metodribic avatar Aug 10 '17 17:08 metodribic

Got the same issue by using 'angular2-notifications' issue. Strangely Webstorm auto imported this package as from 'angular2-notifications/dist' I got it solved by setting it it manually to from 'angular2-notifications'

mattsse avatar Aug 23 '17 13:08 mattsse

Had an issue with declaring a variable inside of a custom forRoot function I've created

Turned that variable into an exported const, and it solved the issue... for some reason, it doesn't like variable declared inside of the forRoot functions.

It also happens with console.log and other non exported function calls according to #17663

shairez avatar Sep 27 '17 12:09 shairez

I tried to define routes like the following and came across this error.

export const routes: Routes = ['open', 'closed', 'processing', 'done']
  .map(status => ({ path: `${status}/list`, component: ListComponent, data: { status } }));

The following code also raised the same error.

export const routes: Routes = ['open', 'closed', 'processing', 'done']
  .map(function(status: string) {
    return { path: `${status}/list`, component: ListComponent, data: { status } };
  });

I also tried the following code, which results in a different error: ERROR in Cannot read property 'loadChildren' of null.

export function createRoute(status: string) {
  return { path: `${status}/list`, component: ListComponent, data: { status } };
}
export const routes: Routes = ['open', 'closed', 'processing', 'done'].map(createRoute);

I ended up using the following code, which works but is disappointing...

export const routes: Routes = [
  { path: 'open/list', component: ListComponent, data: { status: 'open' } },
  { path: 'closed/list', component: ListComponent, data: { status: 'closed' } },
  { path: 'processing/list', component: ListComponent, data: { status: 'processing' } },
  { path: 'done/list', component: ListComponent, data: { status: 'done' }},
];

kimamula avatar Jan 30 '18 06:01 kimamula

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.