angular / universal

Server-side rendering and Prerendering for Angular
MIT License
4.04k stars 483 forks source link

SSR build throws error for NgLocaleLocalization #1622

Closed kshkrao3 closed 4 years ago

kshkrao3 commented 4 years ago

🐞 Bug report

What modules are related to this issue?

Is this a regression?

Yes, the previous version in which this bug was not present was: `Angular 8.x` ### Description Well, I just ran `ng build --prod --aot && ng run myproject:server:production` and when I run `node dist/server/main` it throws below error when I try to access the localhost.
 
Error: Can't resolve all parameters for NgLocaleLocalization: (?).
    at getUndecoratedInjectableFactory (\MyProject\dist\server\main.js:1:4440360)     
    at injectableDefOrInjectorDefFactory (\MyProject\dist\server\main.js:1:4441186)   
    at providerToFactory (\MyProject\dist\server\main.js:1:4442452)
    at providerToRecord (\MyProject\dist\server\main.js:1:4438546)
    at R3Injector.processProvider (\MyProject\dist\server\main.js:1:4438606)
    at provider (\MyProject\dist\server\main.js:1:4438102)
    at input.forEach.value (\MyProject\dist\server\main.js:1:4326776)
    at Array.forEach ()
    at deepForEach (\MyProject\dist\server\main.js:1:4326718)
    at R3Injector.processInjectorType (\MyProject\dist\server\main.js:1:4438062) 
But when I just run `ng serve` it runs fine without any issues. So I suspect the issue is with SSR build. Not really sure if I can reproduce this issue. It was not there until I switched to Angular 9. **package.json**

"dependencies": {
    "@agm/core": "^1.1.0",
    "@agm/snazzy-info-window": "^1.1.0",
    "@angular/animations": "~9.1.1",
    "@angular/cdk": "^9.2.0",
    "@angular/common": "~9.1.1",
    "@angular/compiler": "~9.1.1",
    "@angular/core": "~9.1.1",
    "@angular/fire": "^5.4.2",
    "@angular/forms": "~9.1.1",
    "@angular/localize": "^9.1.1",
    "@angular/platform-browser": "~9.1.1",
    "@angular/platform-browser-dynamic": "~9.1.1",
    "@angular/platform-server": "~9.1.1",
    "@angular/router": "~9.1.1",
    "@ks89/angular-modal-gallery": "^7.2.5",
    "@ng-bootstrap/ng-bootstrap": "^5.1.5",
    "@nguniversal/express-engine": "^9.1.0",
    "@nguniversal/module-map-ngfactory-loader": "8.2.6",
    "angular-count-to": "0.0.3",
    "angular-tilt": "^1.2.0",
    "angular-typing-animation": "^0.5.4",
    "animate-scss": "^3.2.1",
    "animate.css": "^3.7.2",
    "bootstrap": "^4.4.1",
    "classlist.js": "^1.1.20150312",
    "cookieconsent": "^3.1.1",
    "core-js": "^3.6.5",
    "express": "^4.17.1",
    "firebase": "^7.14.0",
    "firebaseui": "4.5.0",
    "firebaseui-angular": "^4.1.0",
    "hammerjs": "^2.0.8",
    "jspdf": "^1.5.3",
    "jspdf-autotable": "^3.4.3",
    "lodash": "4.17.15",
    "moment-timezone": "^0.5.28",
    "mousetrap": "^1.6.5",
    "ng-animate": "^0.3.4",
    "ng2-animate-on-scroll": "^2.0.0",
    "ng2-cookies": "^1.0.12",
    "ng2-scroll-to-el": "^1.2.1",
    "ng5-slider": "^1.2.4",
    "ngx-build-plus": "^9.0.6",
    "ngx-content-loading": "^0.1.3",
    "ngx-cookieconsent": "^2.2.3",
    "ngx-logger": "^4.1.4",
    "ngx-masonry": "^9.0.0",
    "ngx-masonry-gallery": "^3.0.0",
    "ngx-owl-carousel-o": "^3.0.0",
    "ngx-spinner": "^9.0.2",
    "ngx-swiper-wrapper": "^9.0.1",
    "ngx-toastr": "^12.0.1",
    "razorpay": "^2.0.6",
    "rxjs": "^6.5.5",
    "rxjs-compat": "^6.5.5",
    "snazzy-info-window": "^1.1.1",
    "sweetalert2": "^9.10.11",
    "tslib": "^1.11.1",
    "web-animations-js": "^2.3.2",
    "zone.js": "~0.10.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1000.0-next.0",
    "@angular/cli": "^9.1.1",
    "@angular/compiler-cli": "~9.1.1",
    "@angular/language-service": "~9.1.1",
    "@types/express-serve-static-core": "^4.17.4",
    "@types/googlemaps": "^3.39.3",
    "@types/hammerjs": "^2.0.36",
    "@types/jasmine": "~3.5.10",
    "@types/jasminewd2": "~2.0.8",
    "@types/lodash": "^4.14.149",
    "@types/mousetrap": "^1.6.3",
    "@types/node": "^13.11.1",
    "bufferutil": "^4.0.1",
    "codelyzer": "^5.2.2",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.1",
    "karma": "~5.0.1",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~2.1.1",
    "karma-jasmine": "~3.1.1",
    "karma-jasmine-html-reporter": "^1.5.3",
    "localstorage-polyfill": "^1.0.1",
    "protractor": "~5.4.3",
    "replace-in-file": "^5.0.2",
    "serverless-webpack": "^5.3.1",
    "ts-loader": "^6.2.2",
    "ts-node": "~8.8.2",
    "tslint": "~6.1.1",
    "typescript": "^3.8.3",
    "utf-8-validate": "^5.0.2",
    "webpack-cli": "^3.3.11",
    "ws": "^7.2.3",
    "xhr2": "^0.2.0"
  }
I had `import '@angular/localize/init';` in `polyfills.ts` and initially, I thought this was the reason for the error, but when I removed it, it started throwing `$localize() is undefined` error for which the resolution was to include `@angular/localize/init`. I am really stuck on this error and there isn't much information on **Can't resolve all parameters for NgLocaleLocalization: (?).**. ## 🔥 Exception or Error

Error: Can't resolve all parameters for NgLocaleLocalization: (?).
    at getUndecoratedInjectableFactory (\MyProject\dist\server\main.js:1:4440360)     
    at injectableDefOrInjectorDefFactory (\MyProject\dist\server\main.js:1:4441186)   
    at providerToFactory (\MyProject\dist\server\main.js:1:4442452)
    at providerToRecord (\MyProject\dist\server\main.js:1:4438546)
    at R3Injector.processProvider (\MyProject\dist\server\main.js:1:4438606)
    at provider (\MyProject\dist\server\main.js:1:4438102)
    at input.forEach.value (\MyProject\dist\server\main.js:1:4326776)
    at Array.forEach ()
    at deepForEach (\MyProject\dist\server\main.js:1:4326718)
    at R3Injector.processInjectorType (\MyProject\dist\server\main.js:1:4438062) 
## 🌍 Your Environment

Angular CLI: 9.1.1
Node: 10.13.0
OS: win32 x64
Angular:
...
Ivy Workspace:
Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.901.1
@angular-devkit/core         9.1.1
@angular-devkit/schematics   9.1.1
@schematics/angular          9.1.1
@schematics/update           0.901.1
rxjs                         6.5.4
kshkrao3 commented 4 years ago

Does anyone have any idea about this? Angular Team, please look at this once.. :(

CaerusKaru commented 4 years ago

Please provide a minimal reproduction. We cannot simply divine the answer 😄

dineshrawat11 commented 4 years ago

Unhandled Promise rejection: Can't resolve all parameters for NgLocaleLocalization: (?). ; Zone: <root> ; Task: Promise.then ; Value: Error: Can't resolve all parameters for NgLocaleLocalization: (?).

This problem still persists! Did anybody find any solution of this issue!

angular-automatic-lock-bot[bot] commented 4 years ago

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.