*Event/HTML*Element is not defined error in server build
See original GitHub issueBug Report or Feature Request (mark with an x
)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Versions.
Angular CLI: 1.5.0
Node: 8.7.0
OS: win32 x64
Angular: 5.0.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
@angular/cli: 1.5.0
@angular-devkit/build-optimizer: 0.0.32
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.35
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.2
typescript: 2.4.2
webpack: 3.8.1
Repro steps.
- Create new app with
ng new ...
. - Follow https://github.com/angular/angular-cli/wiki/stories-universal-rendering.
- Add
@HostListener('window:click') click(event: MouseEvent) { }
in theapp.component.ts
. - Run
yarn run build:ssr && yarn run serve:ssr
.
Repro: https://github.com/kevinphelps/angular-cli-issue-8412-repro
The log given by the failure.
ReferenceError: MouseEvent is not defined
at C:\Users\Kevin\Desktop\server-test\dist\server.js:129629:12684
at Object.wQAS (C:\Users\Kevin\Desktop\server-test\dist\server.js:129629:12867)
at l (C:\Users\Kevin\Desktop\server-test\dist\server.js:129629:149)
at Object.aR8+ (C:\Users\Kevin\Desktop\server-test\dist\server.js:129629:7591)
at l (C:\Users\Kevin\Desktop\server-test\dist\server.js:129629:149)
at Object.bNRb (C:\Users\Kevin\Desktop\server-test\dist\server.js:129629:7978)
at l (C:\Users\Kevin\Desktop\server-test\dist\server.js:129629:149)
at Object.JwoV (C:\Users\Kevin\Desktop\server-test\dist\server.js:129629:995)
at l (C:\Users\Kevin\Desktop\server-test\dist\server.js:129629:149)
at Object.Zq8w (C:\Users\Kevin\Desktop\server-test\dist\server.js:129629:7299)
Desired functionality.
The use of Event
, MouseEvent
, KeyboardEvent
, HTMLElement
, etc. interfaces should not break the server builds.
Mention any other details that might be useful.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:18 (12 by maintainers)
Top Results From Across the Web
ReferenceError: HTMLElement is not defined in TypeScript
The idea is to create an Observable out of the event stream coming from the Front End element (in your case the Input...
Read more >How to Fix ReferenceError: Event is Not Defined in JavaScript
JavaScript's ReferenceError: Event is Not Defined occurs if the event parameter is not declared correctly when using an event handler.
Read more >The 10 Most Common JavaScript Issues Developers Face
If you need help figuring out why your JavaScript isn't working, consult this list of the 10 most common JavaScript issues from a...
Read more >Four ways of listening to DOM events in Angular (Part 3
This is because there are no global objects such as window or document in environments other than web browsers. We could resolve this...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I just looked into this. There is something strange going on. The compilation and all works as expected. however, when the resulting server.JS is started, it blows up with the mentioned error.
The strange thing is: MouseEvent is used as a type. It should not end up in the JS at all!.
Changing it to type any fixes the current bug, but not in a way we would like to see.
Not sure what is the root cause of this is.
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.