Note: for support questions, please use one of these channels: https://github.com/angular/universal/blob/master/CONTRIBUTING.md#question. This repository's issues are reserved for feature requests and bug reports. Also, Preboot has moved to https://github.com/angular/preboot - please make preboot-related issues there.
- [x] bug report
- [ ] feature request
- [ ] support request => Please do not submit support request here, see note at the top of this template.
- [ ] aspnetcore-engine
- [x] express-engine
- [ ] hapi-engine
bug
when I upgrade from angular 5.0.0 to 5.0.1 EventManager was broken with ReferenceError: Event is not defined
constructor(
private eventManager: EventManager,
) {
}
upgrade angular from 5.0.0 to 5.0.1
Please tell us about your environment:
Angular version: 5.0.1
Platform: [NodeJs ]
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)
ERROR { Error: Uncaught (in promise): ReferenceError: Event is not defined
ReferenceError: Event is not defined
it may be caused by document
I experienced this as well, it seems adding hostlistener may lead to this error too
please have a look at the https://github.com/wpcfan/universal-starter.git, I did not add any document/window stuff, just a directive with @HostListener, and it will cause the error
Thanks for reporting this, looks like a bug to me, will investigate.
@wpcfan if you remove the :Event then you error goes away
me help global['Event'] = null; in server.ts
Got the exact same error and after applying the fix from @Gorniv I get the same error just with FocusEvent and KeyboardEvent. I don't know what could cause this.
Removing the type fixes this
I met the same error when run node dist/server.js. I tried with domino by adding these lines in server.ts
const domino = require('domino');
const fs = require('fs');
const path = require('path');
const Zone = require('zone.js');
const DIST_FOLDER = path.join(process.cwd(), 'dist');
const template = fs.readFileSync(path.join(DIST_FOLDER, 'browser', 'index.html')).toString();
const win = domino.createWindow(template);
const files = fs.readdirSync(`${process.cwd()}/dist/server`);
import fetch from 'node-fetch';
win.fetch = fetch;
global['window'] = win;
global['DOMTokenList'] = win.DOMTokenList;
global['Node'] = win.Node;
global['Text'] = win.Text;
global['HTMLElement'] = win.HTMLElement;
global['navigator'] = win.navigator;
global['Event'] = win.Event;
global['Event']['prototype'] = win.Event.prototype;
Object.defineProperty(win.document.body.style, 'transform', {
value: () => {
return {
enumerable: true,
configurable: true
};
},
});
global['document'] = win.document;
global['CSS'] = null;
So the error disappeared, and I saw another one:
ERROR TypeError: Cannot assign to read only property 'stopImmediatePropagation' of object '[object Object]'
Use global['Event'] = null; just lead me to an other error:
ERROR { Error: Uncaught (in promise): Error: no Promise impl found
Error: no Promise impl found
Any solution for this case now?
I am experiencing this bug as well, but I use aspnetcore-engine.
I created a PR to fix some issues about Event is not defined in here, https://github.com/angular/angular/pull/22905.
@thovo, could you post a reproduce repo about this error
ERROR { Error: Uncaught (in promise): Error: no Promise impl found
Error: no Promise impl found
I am sorry that I can not reproduce for you a repository with that errors. But, to resolve my problem, I isolated the part which had the call with Event by wrapping everything in the condition of platformBrowser and it worked normally now. I hope it could help other with similar issues. Actually, I wrapped almost everything inside of platformBrowser to prevent error like above.
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._
Most helpful comment
me help
global['Event'] = null;in server.ts