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

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 #3707

Closed
Oleg1969 opened this issue Dec 22, 2016 · 98 comments

Comments

@Oleg1969
Copy link

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.

@markmssd
Copy link

Also getting this error, upgrading typescript seems to resolve it (although it might create other errors :/)

@hansl
Copy link
Contributor

hansl commented Dec 22, 2016

angular2-perfect-scrollbar is not publishing metadata, and so is not compatible with Angular CLI. I contacted our relation team and they'll contact that library.

@hansl hansl closed this as completed Dec 22, 2016
@Oleg1969
Copy link
Author

angular2-perfect-scrollbar is just one example , the are plenty modules like that. What you saying all of them will not be compatible with Angular CLI? What that means to us? We can not upgrade because of 3rd party modules simply will stop working. That is kind of odd path. Where would I find information about "publishing metadata" in context with CLI compatibility?

@hansl
Copy link
Contributor

hansl commented Dec 22, 2016

We are working in the future to show a warning for those. I also think it shouldn't be an error, but there are cases where an error can happen because of these libraries (routing for example) and these libraries are not AOT-compatible (at all!).

We have clear guidelines for libraries that include generating those files and what to publish to NPM. If libraries don't follow those guidelines we can't guarantee that they'll be compatible.

And yes, we have report of these a lot, and when I tell the relation team they are actually efficient in dealing with those. So there's hope.

@loicsalou
Copy link

please provide a link to your clear guidelines about publishing compatible library, I'm trying to make one and I'd like it to be compatible.

@antoineabourjeilycme
Copy link

antoineabourjeilycme commented Jan 4, 2017

@hansl I'm having the same problem with Angular-Datatables. is there anything we can do ourselves? or should we always wait for the 3rd party libraries to publish metadata.
Where can I find more about the metadata you're talking about?

@Mage111
Copy link

Mage111 commented Jan 8, 2017

I have same issue. in beta.22 all work fine. but when I upgrade to beta.24 I got the following error:
ERROR in Error encountered resolving symbol values statically. Calling function 'SharedModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in ../src/app/app.module.ts, resolving symbol AppModule in ../src/app/app.module.ts

@Bretto
Copy link

Bretto commented Jan 10, 2017

I have the same issue with:

angular-cli: 1.0.0-beta.24
node: 7.0.0
os: linux x64
@angular/common: 2.4.2
@angular/compiler: 2.4.2
@angular/core: 2.4.2
@angular/forms: 2.4.2
@angular/http: 2.4.2
@angular/platform-browser: 2.4.2
@angular/platform-browser-dynamic: 2.4.2
@angular/router: 3.4.2
@angular/compiler-cli: 2.4.2

Error:

client?93b6:80Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 12:42 in the original .ts file), resolving symbol compose in /data/2017/search-project/node_modules/@ngrx/core/compose.d.ts, resolving symbol appStore in /data/2017/search-project/src/app/main/app.store.ts, resolving symbol appStore in /data/2017/search-project/src/app/main/app.store.ts, resolving symbol appStore in /data/2017/search-project/src/app/main/app.store.ts, resolving symbol AppModule in /data/2017/search-project/src/app/main/app.module.ts, resolving symbol AppModule in /data/2017/search-project/src/app/main/app.module.ts, resolving symbol AppModule in /data/2017/search-project/src/app/main/app.module.ts

@baruchvlz
Copy link
Contributor

@Bretto That seems to be a missing export error.

@Mage111
Copy link

Mage111 commented Jan 10, 2017

I solved it by replace the anonymous (lambda) method to explicitly method:
providers: [ TranslateService, { provide: TranslateLoader, useFactory: translateLoader, deps: [Http] } ]
and following method:
export function translateLoader(http: Http) { return new TranslateStaticLoader(http, 'assets/i18n', '.json');

instead of:
TranslateModule.forRoot({ provide: TranslateLoader, useFactory: (http: Http) => new TranslateStaticLoader(http, '/assets/i18n', '.json'), deps: [Http] })

@Bretto
Copy link

Bretto commented Jan 15, 2017

@baruchvlz the application works, I don't think its a missing export

export const appStore = compose(storeLogger(), combineReducers)({
  items: TntReducer.registerReducer(ItemReducers, itemInitState),
});

With the same code other project on previous version of the CLI had no issues...

Currently the application works but when it starts with a big error like this it doesn't look good/pro...
I have updated the CLI:

angular-cli: 1.0.0-beta.25.5
node: 7.0.0
os: linux x64
@angular/common: 2.4.3
@angular/compiler: 2.4.3
@angular/core: 2.4.3
@angular/forms: 2.4.3
@angular/http: 2.4.3
@angular/platform-browser: 2.4.3
@angular/platform-browser-dynamic: 2.4.3
@angular/router: 3.4.3
@angular/compiler-cli: 2.4.3

but the problem remains.
Is it correct to assume that the issue is in the Ngrx code base ?
How do I fix this ?

@beeman
Copy link
Contributor

beeman commented Jan 18, 2017

please provide a link to your clear guidelines about publishing compatible library, I'm trying to make one and I'd like it to be compatible.

@loicsalou I just came across your comment. You can refer to this guide https://medium.com/@cyrilletuzi/how-to-build-and-publish-an-angular-module-7ad19c0b4464#.9y88ipdk7 on how to make a working module.

@tom10271
Copy link

Error: 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 /Users/pathetic-dev/Sites/my-app/public-html/jspm_packages/npm/@angular/[email protected]/src/di/metadata.d.ts, resolving symbol OpaqueToken in /Users/pathetic-dev/Sites/my-app/public-html/jspm_packages/npm/@angular/[email protected]/src/di/opaque_token.d.ts, resolving symbol OpaqueToken in /Users/pathetic-dev/Sites/my-app/public-html/jspm_packages/npm/@angular/[email protected]/src/di/opaque_token.d.ts
    at simplifyInContext (/Users/pathetic-dev/Sites/my-app/node_modules/@angular/compiler/bundles/compiler.umd.js:25569:27)
    at StaticReflector.simplify (/Users/pathetic-dev/Sites/my-app/node_modules/@angular/compiler/bundles/compiler.umd.js:25581:17)
    at StaticReflector.annotations (/Users/pathetic-dev/Sites/my-app/node_modules/@angular/compiler/bundles/compiler.umd.js:25077:64)
    at NgModuleResolver.resolve (/Users/pathetic-dev/Sites/my-app/node_modules/@angular/compiler/bundles/compiler.umd.js:17557:86)
    at CompileMetadataResolver.getNgModuleMetadata (/Users/pathetic-dev/Sites/my-app/node_modules/@angular/compiler/bundles/compiler.umd.js:18058:64)
    at addNgModule (/Users/pathetic-dev/Sites/my-app/node_modules/@angular/compiler/bundles/compiler.umd.js:24839:62)
    at /Users/pathetic-dev/Sites/my-app/node_modules/@angular/compiler/bundles/compiler.umd.js:24850:18
    at Array.forEach (native)
    at _createNgModules (/Users/pathetic-dev/Sites/my-app/node_modules/@angular/compiler/bundles/compiler.umd.js:24849:30)
    at analyzeNgModules (/Users/pathetic-dev/Sites/my-app/node_modules/@angular/compiler/bundles/compiler.umd.js:24724:18)
Compilation failed

I start using ng2-cli but why official Angular 2 core library will trigger this error? Very frustrated for switching to AoT after over 1 day of trying....

@joidegn
Copy link

joidegn commented Jan 19, 2017

I had the same issue @tom10271. I think your problem is different than op's. Please check if you have a node_modules folder in ./src folder and if so remove it.

@apelleti
Copy link

apelleti commented Jan 25, 2017

@Bretto I have the same problem. In localhost, it's working even if there is the error. But with Jenkins, the build crash.
Any update ?

@Bretto
Copy link

Bretto commented Jan 25, 2017

My Custom Module and the App had different versions of Ng2. After I updated both to the last version of angular the issue disappeared in my case. Hope this helps...

@richardsengers
Copy link

The error even shows up when your using "window." or "location." in your environment file :s
Is it incorrect to use window and location in an Angular 2 app?

@anrepppp
Copy link

anrepppp commented Feb 1, 2017

I am getting the same error, i tried to fix it by converting into an export function:
Problem:
{provide: APP_INITIALIZER, useFactory: (config: AppConfig) => () => config.load(), deps: [AppConfig], multi: true },
Step1:
export function textFunction(config: AppConfig): any {
() => {
config.load()
}
}

{provide: APP_INITIALIZER, useFactory: textFunction, deps: [AppConfig], multi: true },

Error: AppInits[i] is not a function

Step2:
export function textFunction(config: AppConfig) {
return config.load();
}
{provide: APP_INITIALIZER, useFactory: textFunction, deps: [AppConfig], multi: true },

Error: AppInits[i] is not a function

When i convert into an export function compiler error gets disappeared but the app breaks with appInits[i] is not a function. Can you please guide me how to convert appIntializer useFactory to an export method.

@psancho
Copy link

psancho commented Feb 1, 2017

I get the same error with angular2-cool-storage
Linux x64
[email protected]
[email protected]
[email protected]
[email protected]
Unfortunately, I see no lambda in imports statement:

import { CoolStorageModule } from 'angular2-cool-storage'; @NgModule({ imports: [CoolStorageModule], }) export class CoreModule {}
results in:
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,...

@maxruby
Copy link

maxruby commented Jul 5, 2017

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?

vuvuzella added a commit to vuvuzella/db-training-app that referenced this issue Jul 11, 2017
@x1unix
Copy link

x1unix commented Jul 17, 2017

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

@AABRHALEY
Copy link

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
Copy link

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.

@metodribic
Copy link

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

@SarraMrbt
Copy link

SarraMrbt commented Jul 27, 2017

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

@umagon
Copy link

umagon commented Aug 9, 2017

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.

@metodribic
Copy link

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

@umagon
Copy link

umagon commented Aug 10, 2017

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

@metodribic
Copy link

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

@mattsse
Copy link

mattsse commented Aug 23, 2017

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'

@shairez
Copy link
Contributor

shairez commented Sep 27, 2017

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

Bielik20 added a commit to Bielik20/LazyForms that referenced this issue Dec 4, 2017
Issue with providing with lambda: angular/angular-cli#3707
Bielik20 added a commit to Bielik20/LazyForms that referenced this issue Dec 4, 2017
Issue with providing with lambda: angular/angular-cli#3707
@kimamula
Copy link

kimamula commented Jan 30, 2018

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' }},
];

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests