Hi guys,
I have just tried to create new Aurelia 2 app with npx makes aurelia
, choosing:
Default TypeScript Aurelia 2 App
After running:
npm install
npm start
Aurelia 2 application brakes in the browser with following error:
Uncaught TypeError: Cannot read properties of undefined (reading 'addEventListener')
at aurelia.js?v=d61b605d:16628:14
at onResolve (aurelia.js?v=d61b605d:433:10)
at new AppRoot (aurelia.js?v=d61b605d:16626:28)
at _Aurelia.app (aurelia.js?v=d61b605d:16754:17)
at _Aurelia.app (aurelia.js?v=d61b605d:20435:18)
at _Aurelia.app (aurelia.js?v=d61b605d:20415:27)
at main.ts:5:4
Line that breaks is:
host.addEventListener("submit", (e) => {
const target = e.target;
const noAction = !target.getAttribute("action");
if (target.tagName === "FORM" && noAction) {
e.preventDefault();
}
}, false);
because host
is undefined. This line is part of AppRoot
class and it’s constructor
.
What am I missing here? How do I fix this error?