Closed mohamedHassanee closed 4 years ago
Kindly see: https://github.com/angular/universal/blob/master/docs/gotchas.md
If the problem persists, kindly file a new issue with a minima reproduction.
Thanks
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.
i followed this link https://trilon.io/blog/angular-universal-v9-whats-new#What-s-new-with-Angular-Universal- to apply ssr for my app i installed universal by
ng add @nguniversal/express-engine@next
then i used this commandnpm run dev:ssr
after successful compilation i got the following error: `Compiled successfully. F:\Work\stc\GitHub\frontend\eforms-app\dist\eforms-app\server\main.js:273178 })(window, function(__WEBPACK_EXTERNAL_MODULE_knockout, WEBPACK_EXTERNAL_MODULE_survey_knockout__) { ^ReferenceError: window is not defined at Object../node_modules/survey-creator/survey-creator.js (F:\Work\stc\GitHub\frontend\eforms-app\dist\eforms-app\server\main.js:273178:4) at webpack_require (F:\Work\stc\GitHub\frontend\eforms-app\dist\eforms-app\server\main.js:20:30) at Object../src/app/core/survey/surevey-settings/survey-settings.ts (F:\Work\stc\GitHub\frontend\eforms-app\dist\eforms-app\server\main.js:356044:23) at webpack_require (F:\Work\stc\GitHub\frontend\eforms-app\dist\eforms-app\server\main.js:20:30) at Object../src/app/pages/eforms/eforms.component.ts (F:\Work\stc\GitHub\frontend\eforms-app\dist\eforms-app\server\main.js:358302:24) at webpack_require (F:\Work\stc\GitHub\frontend\eforms-app\dist\eforms-app\server\main.js:20:30) at Object../src/app/app-routing.module.ts (F:\Work\stc\GitHub\frontend\eforms-app\dist\eforms-app\server\main.js:354661:28) at webpack_require (F:\Work\stc\GitHub\frontend\eforms-app\dist\eforms-app\server\main.js:20:30) at Object../src/app/app.module.ts (F:\Work\stc\GitHub\frontend\eforms-app\dist\eforms-app\server\main.js:354829:30) at __webpack_require__ (F:\Work\stc\GitHub\frontend\eforms-app\dist\eforms-app\server\main.js:20:30)
A server error has occurred. node exited with 1 code. connect ECONNREFUSED 127.0.0.1:52185 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! eforms-app@0.0.0 dev:ssr:
ng run eforms-app:serve-ssr
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the eforms-app@0.0.0 dev:ssr script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\mohamed.mohamed\AppData\Roaming\npm-cache_logs\2020-07-13T05_59_03_484Z-debug.log`
after search i found that i should to put some code in server.ts like: `const domino = require("domino");
const win = domino.createWindow(indexHtml);
win.Object = Object;
win.Math = Math;
global["window"] = win;
global["document"] = win.document;
global["branch"] = null;
global["object"] = win.object;
global["HTMLElement"] = win.HTMLElement;
global["navigator"] = win.navigator;
global["localStorage"] = localStorage;
global["sessionStorage"] = localStorage;`
but still the error exists.
full server.ts code is : `
`