angular-universal

Update to Angular v6 - Module not found: Error: Can't resolve 'fs'

天大地大妈咪最大 提交于 2019-11-29 06:11:04
I'm trying to migrate my Angular Universal project from Angular v5 to v6 I've got a service where I use fs to load the translation on the server side. Everything works well with Angular v5. With Angular v6, when I run npm run start aka ng serve --proxy-config proxy.conf.json I face the following error ERROR in ./src/providers/core/translate/translate-universal-loader.service.ts Module not found: Error: Can't resolve 'fs' in '/Users/me/Documents/projects/myproject/src/providers/core/translate' In my service I declare fs like the following: declare var require: any; const fs = require('fs'); I

How to get full base URL (including server, port and protocol) in Angular Universal?

本秂侑毒 提交于 2019-11-28 12:26:54
I need to get the full base URL (e.g. http://localhost:5000 or https://productionserver.com ) of my Angular 2 app so that I can pass it along to a 3rd party service in the context of the app. The app's location varies depending on whether it is development, various staging/testing environments, or production, and I'd like to detect it dynamically so I don't need to maintain a hard-coded list. A similar question has been posed in the past, but the answers (i.e. use some version of the window.location.hostname or window.location.origin property) only work when the angular2 app is being rendered

Angular isPlatformBrowser checking against PLATFORM_ID doesn't prevent server-side pre rendering

时光总嘲笑我的痴心妄想 提交于 2019-11-28 03:59:43
问题 I am trying to compile Angular 4 + ASP.NET Universal application created based on sample project here, using this hints https://github.com/angular/universal#universal-gotchas and when I build project with webpack, and then run it there is error thrown as the code that was encapsulated inside if block checked against isPlatformBrowser was prerendered on server side . How to effectively enforce execution of this code on client side without prerendering, while other code that works appropriately

(Angular 6) Angular Universal - Not waiting on content API call

馋奶兔 提交于 2019-11-27 23:45:26
问题 Cannot get SSR to work when using Angular Universal with pages that use dynamic content. All other pages work and the dynamic pages return with HTML but do not include the dynamic data. Method Called: ngOnInit() { const div = this.renderer.createElement('div'); const texttest = this.renderer.createText('this works'); this.renderer.appendChild(div, texttest); this.renderer.appendChild(this.content.nativeElement, div); this.createLinkForCanonicalURL(); // The HTML never shows, the method works

How to set up Angular cli + Angular universal?

戏子无情 提交于 2019-11-27 19:53:31
Anyone have experience with installing angular universal with angular cli projects? I tried to follow this guide: https://universal.angular.io/quickstart/ But after I do this: typings install node express body-parser serve-static express-serve-static-core mime --global I get error: typings INFO globaldependencies "express" lists global dependencies on "node" that must be installed manually typings ERR! message Unable to find "node" ("npm") in the registry. typings ERR! message However, we found "node" for 2 other sources: "dt" and "env" typings ERR! message You can install these using the

Need BrowserAnimationsModule in Angular but gives error in Universal

狂风中的少年 提交于 2019-11-27 14:14:29
Hi I am using Angular that uses the BrowserAnimationsModule. But in the universal server side it gives the error "document is not defined". Because Universal doesn't support BrowserAnimationsModule I need a way to make the server ignore BrowserAnimationsModule and replace it with NoopAnimationsModule. This is what I have right now but it's not working. Any other methods are welcome too. let imports = [ BrowserModule.withServerTransition({appId: 'ang4-seo'}), FormsModule, HttpModule, routes ]; if(isPlatformBrowser(PLATFORM_ID)){ imports.push(BrowserAnimationsModule); } @NgModule({ imports:

How to get full base URL (including server, port and protocol) in Angular Universal?

三世轮回 提交于 2019-11-27 06:54:56
问题 I need to get the full base URL (e.g. http://localhost:5000 or https://productionserver.com) of my Angular 2 app so that I can pass it along to a 3rd party service in the context of the app. The app's location varies depending on whether it is development, various staging/testing environments, or production, and I'd like to detect it dynamically so I don't need to maintain a hard-coded list. A similar question has been posed in the past, but the answers (i.e. use some version of the window

“Unexpected token import” error with Angular4 + Universal + ng-bootstrap

孤人 提交于 2019-11-27 06:01:36
问题 So I upgraded to angular 4+ just so that I can leverage the universal package for server side rendering for SEO purposes. I implemented that in my existing angular 2+ project by upgrading it to angular 4+ and did all the necessary configuration from https://github.com/evertonrobertoauler/cli-universal-demo/commit/a2610286bd3db5d4f4cce4318d7c220c11963eb6. There is only one difference I am using ng-bootstrap https://ng-bootstrap.github.io/#/home (v1.0.0-alpha.22). But when I run the node server

How to set up Angular cli + Angular universal?

一世执手 提交于 2019-11-27 04:24:28
问题 Anyone have experience with installing angular universal with angular cli projects? I tried to follow this guide: https://universal.angular.io/quickstart/ But after I do this: typings install node express body-parser serve-static express-serve-static-core mime --global I get error: typings INFO globaldependencies "express" lists global dependencies on "node" that must be installed manually typings ERR! message Unable to find "node" ("npm") in the registry. typings ERR! message However, we

Need BrowserAnimationsModule in Angular but gives error in Universal

限于喜欢 提交于 2019-11-26 18:20:47
问题 Hi I am using Angular that uses the BrowserAnimationsModule. But in the universal server side it gives the error "document is not defined". Because Universal doesn't support BrowserAnimationsModule I need a way to make the server ignore BrowserAnimationsModule and replace it with NoopAnimationsModule. This is what I have right now but it's not working. Any other methods are welcome too. let imports = [ BrowserModule.withServerTransition({appId: 'ang4-seo'}), FormsModule, HttpModule, routes ];