Solvedangular cli Error encountered resolving symbol values statically

Please provide us with the following information:

OS?

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

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:
@angular/cli: 1.0.0-beta.32.3 [1.0.0-beta.24]
node: 6.10.0
os: linux x64
@angular/common: 2.4.8
@angular/compiler: 2.4.8
@angular/core: 2.4.8
@angular/flex-layout: 2.0.0-beta.5
@angular/forms: 2.4.8
@angular/http: 2.4.8
@angular/material: 2.0.0-beta.2
@angular/platform-browser: 2.4.8
@angular/platform-browser-dynamic: 2.4.8
@angular/router: 3.4.8
@angular/compiler-cli: 2.4.8
@angular/cli: 1.0.0-beta.32.3

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.
We did development on Windows/Mac. For production, we chose ubuntu. Fresh machine. Everything installed fresh. When we compile, we get following error

package.json file

{
  "name": "glam",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^2.3.1",
    "@angular/compiler": "^2.3.1",
    "@angular/core": "^2.3.1",
    "@angular/flex-layout": "^2.0.0-beta.1",
    "@angular/forms": "^2.3.1",
    "@angular/http": "^2.3.1",
    "@angular/material": "^2.0.0-beta.2",
    "@angular/platform-browser": "^2.3.1",
    "@angular/platform-browser-dynamic": "^2.3.1",
    "@angular/router": "^3.3.1",
    "@angular2-material/core": "^2.0.0-alpha.8-2",
    "angular-2-local-storage": "^1.0.0",
    "angular2-onsenui": "^1.0.0-rc.4",
    "core-js": "^2.4.1",
    "hammerjs": "^2.0.8",
    "ng2-material": "^0.8.1",
    "ng2-page-scroll": "^4.0.0-beta.2",
    "onsenui": "^2.0.5",
    "primeng": "^1.1.2",
    "rxjs": "^5.0.1",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.2"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^2.3.1",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "@angular/cli": "1.0.0-beta.32.3",
    "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-remap-istanbul": "^0.2.1",
    "protractor": "~4.0.13",
    "ts-node": "1.2.1",
    "tslint": "^4.0.2",
    "typescript": "~2.0.3"
  }
}

The log given by the failure.

Normally this include a stack trace and some more information.

ng build
10% building modules 3/3 modules 0 active(node:24869) DeprecationWarning: loaderUtils.parseQuery() received a non-string value which can be problematic, see webpack/loader-utils#56
parseQuery() will be replaced with getOptions() in the next major version of loader-utils.
Hash: aadb17976632b415a446
Time: 23846ms
chunk {0} main.bundle.js, main.bundle.js.map (main) 180 kB {2} [initial] [rendered]
chunk {1} styles.bundle.js, styles.bundle.js.map (styles) 194 kB {3} [initial] [rendered]
chunk {2} vendor.bundle.js, vendor.bundle.js.map (vendor) 5.22 MB [initial] [rendered]
chunk {3} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]

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 /home/glamstudios/mobilesite/src/app/app.module.ts, resolving symbol AppModule in /home/glamstudios/mobilesite/src/app/app.module.ts

Mention any other details that might be useful.


Thanks! We'll be in touch soon.

24 Answers

✔️Accepted Answer

This is like the 6th different error i have gotten while trying to configure AOT. The angular team should not put out code until it has been properly tested.
My code works absolutely fine with JIT. As soon as AOT comes into the picture, i get a tidal wave of errors.

Other Answers:

This is an Angular compiler problem really not CLI problem.

convert any lambda () => something or function function something() {} to use export like:

export function getFlexLayoutModule() {
  return FlexLayoutModule;
}

Karasuni, Angular 2 AOT is broken right now. I wasted over a week trying to update my project to work with AOT. Now I am extremely far behind, and AOT still doesn't work. My advice is to just use the Uglify plugin.

I get this error, when i first run build watch, but later when i change a file, it builds fine, :/ strange

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 36:31 in the original .ts file), resolving symbol routes in E:/www/htdoc
s/website/admin-src/src/app/app.routing.ts, resolving symbol AppRoutingModule in E:/www/htdocs/website/admin-src/src/app/app.routing.ts, resolving symbol AppRoutingModule in E:/www/htdocs/website/admin-src/src/app/app.routing.ts, resolving s
ymbol AppRoutingModule in E:/www/htdocs/website/admin-src/src/app/app.routing.ts

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.

Also, the examples shown in https://angular.io/docs/ts/latest/cookbook/aot-compiler.html are not using the CLI so they are very different.

More Issues: