question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

*Event/HTML*Element is not defined error in server build

See original GitHub issue

Bug 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.

  1. Create new app with ng new ....
  2. Follow https://github.com/angular/angular-cli/wiki/stories-universal-rendering.
  3. Add @HostListener('window:click') click(event: MouseEvent) { } in the app.component.ts.
  4. 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:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:18 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
SanderEliascommented, Nov 13, 2017

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.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 9, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >
Docs • Svelte
Complete documentation for Svelte.
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found