Skip to content

Getting 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 #4647

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

Closed
xtianus79 opened this issue Feb 13, 2017 · 61 comments

Comments

@xtianus79
Copy link

OS?

MacOS Sierre

Versions.

angular-cli: 1.0.0-beta.19-3
node: 6.2.2
os: darwin x64

Repro steps.

Getting this error with using Angular CLI

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/mbp06/Repos/multiple-date-picker-a2/node_modules/@angular/core/src/di/metadata.d.ts, resolving symbol OpaqueToken in /Users/mbp06/Repos/multiple-date-picker-a2/node_modules/@angular/core/src/di/opaque_token.d.ts, resolving symbol OpaqueToken in /Users/mbp06/Repos/multiple-date-picker-a2/node_modules/@angular/core/src/di/opaque_token.d.ts
@xtianus79 xtianus79 changed the title Getting 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/mbp06/Repos/multiple-date-picker-a2/node_modules/@angular/core/src/di/metadata.d.ts, resolving symbol OpaqueToken in /Users/xxxx/node_modules/@angular/core/src/di/opaque_token.d.ts Getting 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 Feb 13, 2017
@webernir
Copy link

webernir commented Feb 13, 2017

same here.
i've fixed that by extracting to a function.
so this:

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

become this:

function httpFactory(http: Http) {
  return new TranslateStaticLoader(http, '/assets/i18n', '.json');
}

TranslateModule.forRoot({
      provide: TranslateLoader,
      useFactory: httpFactory,
      deps: [Http]
    })

but it didn't happen before.
any better fix?

image

@webernir
Copy link

also re-opened at #3707

@ghost
Copy link

ghost commented Feb 13, 2017

I'm getting this error on FlexLayoutModule when trying to run my app.
If I do a dummy edit in some file and hit "ctrl + s" again, it compiles but console dumps out:

FlexLayoutModule.forRoot() has been deprecated and is no longer needed

I'm using Angular v2.4.7 and Angular CLI v1.0.0-beta.31.

@marioleed
Copy link

I also found some strange things: #3674 (comment)

@zagros
Copy link

zagros commented Feb 18, 2017

Getting the exact same issue with a brand new application I just made now.

When I do

./node_modules/.bin/ng-xi18n -p ./src/tsconfig.json

I get this:

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 exp
ed function, resolving symbol Injectable in D:/Temp/newprj--fe/node_modules/@angular/core/src/di/metadata.d.ts, resolving symbol OpaqueToken in D:/Temp/newprj--fe/node_modules/@angular/core/src
/opaque_token.d.ts, resolving symbol OpaqueToken in D:/Temp/newprj--fe/node_modules/@angular/core/src/di/opaque_token.d.ts
    at SyntaxError.BaseError [as constructor] (D:\Temp\newprj--fe\node_modules\@angular\compiler\bundles\compiler.umd.js:1597:31)
    at new SyntaxError (D:\Temp\newprj--fe\node_modules\@angular\compiler\bundles\compiler.umd.js:1795:20)
    at simplifyInContext (D:\Temp\newprj--fe\node_modules\@angular\compiler\bundles\compiler.umd.js:25783:27)
    at StaticReflector.simplify (D:\Temp\newprj--fe\node_modules\@angular\compiler\bundles\compiler.umd.js:25795:17)
    at StaticReflector.annotations (D:\Temp\newprj--fe\node_modules\@angular\compiler\bundles\compiler.umd.js:25291:64)
    at NgModuleResolver.resolve (D:\Temp\newprj--fe\node_modules\@angular\compiler\bundles\compiler.umd.js:17771:86)
    at CompileMetadataResolver.getNgModuleMetadata (D:\Temp\newprj--fe\node_modules\@angular\compiler\bundles\compiler.umd.js:18272:64)
    at addNgModule (D:\Temp\newprj--fe\node_modules\@angular\compiler\bundles\compiler.umd.js:25053:62)
    at D:\Temp\newprj--fe\node_modules\@angular\compiler\bundles\compiler.umd.js:25064:18
    at Array.forEach (native)
Extraction failed

Here's my package.json

"dependencies": {
    "@angular/common": "^2.4.8",
    "@angular/compiler": "^2.4.8",
    "@angular/compiler-cli": "^2.4.8",
    "@angular/core": "^2.4.0",
    "@angular/forms": "^2.4.8",
    "@angular/http": "^2.4.8",
    "@angular/platform-browser": "^2.4.8",
    "@angular/platform-browser-dynamic": "^2.4.8",
    "@angular/router": "^3.4.8",
    "angular-cli": "^1.0.0-beta.28.3",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "ng2-bootstrap": "^1.3.3",
    "rxjs": "^5.0.1",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.2"
  },
  "devDependencies": {
    "@angular/cli": "1.0.0-beta.31",
    "@angular/compiler-cli": "^2.4.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "protractor": "~5.1.0",
    "ts-node": "1.2.1",
    "tslint": "^4.3.0",
    "typescript": "~2.0.0"
  }

@da45
Copy link

da45 commented Feb 20, 2017

I got the following message:
ERROR in Error encountered resolving symbol values statically. Calling function 'FlexLayoutModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in C:/(....)/src/app/app.module.ts, resolving symbol AppModule in C:/(....)/src/app/app.module.ts

but application works fine,

@1-0-1
Copy link

1-0-1 commented Mar 9, 2017

This error can also be thrown by referencing modules outside of your project directory. If you have a shared folder that you keep re-usable modules and are referencing modules in that directory through relative references you will get this error, also. Using a symbolic link to the shared directory fixed this issue for me.

@filipesilva
Copy link
Contributor

Heya, errors like Error encountered resolving symbol values statically mean that there has been some problem in statically analyzing your app.

The CLI always runs statical analysis on code to ensure it will run when compiled with AOT. This may cause a lot of static analysis errors to surface when importing your project into the CLI, or upgrading for older versions where we didn't run this kind of analysis.

A good resource on how to to debug these errors is https://github.com/rangle/angular-2-aot-sandbox#aot-dos-and-donts.

@1-0-1
Copy link

1-0-1 commented Mar 10, 2017

Why am I being blindsided? When I run the build with the --dev flag, everything works. Running it with the --prod flag breaks the build. WHY?!?!?! I'm getting really tired of error messages that don't help. If it is in @angular, it shouldn't be my concern. Tell me what in my code is now magically breaking when it was working fine in non-production mode.
Thanks for letting me vent. Onto 12 hours today and I've got to get the production build done with no clue as to why it is breaking before I can break for the day...

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 .../node_modules/@angular/core/src/di/metadata.d.ts, resolving symbol OpaqueToken in .../node_modules/@angular/core/src/di/opaque_token.d.ts, resolving symbol OpaqueToken in .../node_modules/@angular/core/src/di/opaque_token.d.ts

@dehru
Copy link

dehru commented Mar 10, 2017

I find it very "Opaque"

@ferdis
Copy link

ferdis commented Mar 20, 2017

I believe this to be a bug as well. I get the warning, but once I save a source file the error disappears and the build completes successfully.

@snaikaw
Copy link

snaikaw commented Mar 25, 2017

I was getting this error just now, but it turned out that the syntax error was in my HTML file. I had a messed up HEAD tag without a proper closing tag. Once I fixed that, the compile happened fine. So look out for errors in HTML too.

@kareljuricka
Copy link

@snaikaw same happened to me but when I run ng serve again, the error returned but after some onChange recompilation disappeared with success.

@code-tree
Copy link

or upgrading for older versions where we didn't run this kind of analysis.

@filipesilva What older versions are you referring to here? I'm trying to upgrade from 2.3 to 4.0 and am getting below. Since it doesn't reference any of my own code I have no idea what is causing it. Have the AOT rules changed between 2.3 and 4.0 at all? Thanks

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 /project/node_modules/@angular/core/core.d.ts, resolving symbol ɵf in /project/node_modules/@angular/core/core.d.ts, resolving symbol ɵf in /project/node_modules/@angular/core/core.d.ts

@scote1977
Copy link

@1-0-1 ng build -prod now enables aot by default if I'm not mistaken. You can still use ng build -prod -aot=false.

@gnesher
Copy link

gnesher commented Mar 30, 2017

@filipesilva don't you think that after 6-7 months of the initial release it's time to have an official document on how to get AOT working? I love the work the Rangle.io guys have done and it's super helpful, but it's not complete and still leaves quite a bit of guesswork...

@n4uoase
Copy link

n4uoase commented Apr 3, 2017

Why is this issue closed? Seems that lot of people running in the very same error.
So do I, I exactly get the 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 client-app/node_modules/ng2-breadcrumb/node_modules/@angular/core/core.d.ts

Anybody able to help with this?

@gnesher
Copy link

gnesher commented Apr 3, 2017

@n4uoase I do believe the Angular team does not consider this a "problem" more like a community challenge...

@Orodan
Copy link

Orodan commented Apr 3, 2017

+1 getting the same error when trying to update from 2.4 to 4.0.

@microchip78
Copy link

Same with me ... upgarded angular-cli from beta to release ... and problem appearing in one of the angular module ...

@n4uoase
Copy link

n4uoase commented Apr 4, 2017

@gnesher I do not hope so. We have enough challenges in our code, we don't need challenges in foreign code also :-)
So what can we do? I need to compile the code to get in running on our server.

@gnesher
Copy link

gnesher commented Apr 4, 2017

@n4uoase you can try to reach out to the developers through gitter, they are usually responsive and will try to help - though frankly that fact that they've not updated the docs to reflect these problems after 7 months means this can't be a mistake. Personally I've decided to switch frameworks on all new projects. I'm only here trying to maintain a single legacy application. It's funny how an Angular2 application became legacy after 6 months of use...

@Simon-Briggs
Copy link

I got the same error upgrading from angular 2.4 to angular 4.0.

The library I was relying on had angular 2.4 as a dependency in their package.json. Changing that to a more relaxed peerDependency >2.4 or devDependency >2.4, fixed the issue for me.

@chinenyem
Copy link

Simon could you explain in detail what you did? I am getting the same error. it would be a great help.

@Simon-Briggs
Copy link

In the failing library's package.json I changed:

"dependencies": {
    "@angular/common": "^2.3.1",
    etc....
}

to

"peerDependencies": {
    "@angular/common": ">=2.3.1",
    etc....
}

@amolpshinde07
Copy link

facing below issue when importing function from module as 'RiaCommonsModule.forRoot()'

ERROR in Error encountered resolving symbol values statically. Calling function 'RiaCommonsModule', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol getRiaCommonsModule in D:/SureCall/Angular-CLI/AnC-Client/src/app/app.module.lib.ts, resolving symbol AppModuleLib in D:/SureCall/Angular-CLI/AnC-Client/src/app/app.module.lib.ts, resolving symbol AppModuleLib in D:/SureCall/Angular-CLI/AnC-Client/src/app/app.module.lib.ts

@Mumumurilo
Copy link

Mumumurilo commented Jul 12, 2017

@trekhleb 's solution did not work for me, unfortunately. I have the exact same error as him, and I don't have any yarn-linked projects (although I have one external project being referenced in a lot of components, but I reference it directly, not via yarn link).

I have specified paths in the tsconfig.json file but I still receive the same error:

Error: Error encountered resolving symbol values statically. Calling function 'makeParamDecorator', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol Injectable in /Users/muriloromera/Documents/Git Repos/reserva-de-espacos/Shared/node_modules/@angular/core/src/di/metadata.d.ts, resolving symbol OpaqueToken in /Users/muriloromera/Documents/Git Repos/reserva-de-espacos/Shared/node_modules/@angular/core/src/di/opaque_token.d.ts, resolving symbol OpaqueToken in /Users/muriloromera/Documents/Git Repos/reserva-de-espacos/Shared/node_modules/@angular/core/src/di/opaque_token.d.ts

@sciborrudnicki
Copy link

@trekhleb for me it is working too ... thank you.

@lukeclifton
Copy link

Adding "paths": { "@angular/*": ["../node_modules/@angular/*"] }, in tsconfig.json file worked for me too. Thanks @trekhleb.

@trickmeyer
Copy link

I followed @Simon-Briggs April 4 suggestion, and in addition removed the dependency's node_modules folder. Working fine now.

@Fiv38
Copy link

Fiv38 commented Jul 24, 2017

@trekhleb 's solution didnt work for me too. I added path in tsconfig.json file but still receive the same error

@ilia5050
Copy link

ilia5050 commented Jul 27, 2017

I've got ng2-translate modul TranslateStaticLoader problem like @webernir. his solution can't fixed my problem, but after I add "export" keyword to his httpFactory function error fixed, like this:
...
export function httpFactory(http: Http) {
return new TranslateStaticLoader(http, '/assets/i18n', '.json');
}
...
hope this helps someone

@Fiv38
Copy link

Fiv38 commented Aug 9, 2017 via email

@deepthan
Copy link

I made this mistake when I created a new project, but tried all the solutions failed, what should I do?

@lauradelarie
Copy link

Plus one

@leticiafatimaa
Copy link

@trekhleb for me it is working too :D

@martinsik
Copy link

martinsik commented Oct 8, 2017

Just FYI there's now official troubleshooting guide for this error https://angular.io/guide/metadata#function-calls-are-not-supported.

None of the things listed there helped me.

It turned out the problem was that the library I'm developing didn't specify typings in its package.json.

@qasimraza1979
Copy link

qasimraza1979 commented Oct 10, 2017

@trekhleb your solution does not work for me. I am getting following error message when trying to import angular-seed-library into a ionic project.

1: I have tried "paths": { "@angular/": ["../node_modules/@angular/"] } in both tsconfig of angular-seed-library and also in ionic project no solution still the same error.
2: This error appears if I do yarn link and then run ionic-app-scripts build --prod
3: its over a month now since I am struck with this error. I do hope you understand my position here now :( I will really appreciate, if any one can help on this.

LoginComponent is a component that I have made in angular-library-seed at the moment its very simple and basic component.

$ yarn build:aot
yarn build:aot v0.27.5
$ ionic-app-scripts build --prod
[23:38:18]  ionic-app-scripts 2.1.4
[23:38:18]  build prod started ...
[23:38:18]  clean started ...
[23:38:18]  clean finished in 1 ms
[23:38:18]  copy started ...
[23:38:18]  ngc started ...
[23:38:21]  ionic-app-script task: "build"
[23:38:21]  Error: 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 756:18 in the original .ts file),

resolving symbol Component in C:/Monsenso-Source/administration/node_modules/@monsenso/ 
components/node_modules/@angular/core/core.d.ts,

resolving symbol LoginComponent in C:/Monsenso-Source/administration/node_modules/@monsenso/
components/lib/components/login/login.component.d.ts,

resolving symbol LoginComponent in C:/Monsenso-Source/administration/node_modules/@monsenso/ 
components/lib/components/login/login.component.d.ts

Error: 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 756:18 in the original
 .ts file), resolving symbol Component in 
C:/Monsenso-Source/administration/node_modules/@monsenso/components/node_modules/ 
@angular/core/core.d.ts,

resolving symbol LoginComponent in C:/Monsenso-Source/administration/node_modules/@monsenso/
 components/lib/components/login/login.component.d.ts, 
resolving symbol LoginComponent in C:/Monsenso-Source/administration/node_modules/@monsenso/ 
components/lib/components/login/login.component.d.ts

    at positionalError (C:\Monsenso-Source\administration\node_modules\@angular\compiler\bundles\ 
compiler.umd.js:25266:35)

    at simplifyInContext (C:\Monsenso-Source\administration\node_modules\@angular\compiler\ 
bundles\compiler.umd.js:25109:27)

    at StaticReflector.simplify (C:\Monsenso-Source\administration\node_modules\@angular\compiler\ 
bundles\ compiler.umd.js:25123:13)

    at StaticReflector.annotations (C:\Monsenso-ource\administration\node_modules\@angular\compiler\ 
bundles\compiler.umd.js:24553:41)

    at NgModuleResolver.resolve (C:\Monsenso-Source\administration\node_modules\@angular\ 
compiler\ bundles\compiler.umd.js:14891:70)
    at CompileMetadataResolver.getNgModuleMetadata (C:\Monsenso-Source\administration\node_modules\@angular\compiler\bundles\compiler.umd.js:15546:60)
    at addNgModule (C:\Monsenso-Source\administration\node_modules\@angular\compiler\bundles\compiler.umd.js:24403:58)
    at C:\Monsenso-Source\administration\node_modules\@angular\compiler\bundles\compiler.umd.js:24414:14
    at Array.forEach (native)
    at _createNgModules (C:\Monsenso-Source\administration\node_modules\@angular\compiler\bundles\compiler.umd.js:24413:26)
error Command failed with exit code 1.

@jbeckton
Copy link

wow, I wonder if React developers are dealing with issues like this?

@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