Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

John Piaz
1,713 PointsIt throws this error: Uncaught TypeError: Cannot read property 'addEventListener' of null at app.js:4
I looked at the HTML very carefully and there was not any errors. But it still says: Uncaught TypeError: Cannot read property 'addEventListener' of null at app.js:4
1 Answer

John Piaz
1,713 PointsThank you. I figured out what the problem was; I put the script tags after the HTML.
Brandon White
Full Stack JavaScript Techdegree Graduate 34,660 PointsBrandon White
Full Stack JavaScript Techdegree Graduate 34,660 PointsHi Lucas,
Youβd really need to post your code in order for someone to offer the best advice, as itβs difficult to debug without being able to test code.
That said, based on the error and a review of the video, Iβm guessing that your myButton variable (Iβm assuming youβre calling addEventListener on myButton) doesnβt actually hold a value. This would happen if the element youβre trying to select canβt be found in the DOM.
Try logging out whatever variable youβre calling addEventListener on to see if it holds a value.