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! While you're at it, check out some resources Treehouse students have shared here.

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

JavaScript

TypeError: Cannot read property 'get' of undefined

I followed the video and used the express.Router(). However, when I tried to use router.get(...), I kept getting the error: 'TypeError: Cannot read property 'get' of undefined.' People from stackoverflow were saying Router.() wouldn't work for express 3.x, so I upgraded the bower.json's express dependency to 4.13.4. Nevertheless, the express dependency in package.json is 3.x version. The problem didn't get solved. Any help would be appreciated. (PS: I am use Yoeman and meanstack generator)

1 Answer

Seth Kroger
Seth Kroger
56,413 Points

Bower manages client-side dependencies. Server-side dependencies the responsibility of npm, so you'll have to update the versions in package.json and run npm update.

Thanks! @Seth Kroger. I see. May I ask how to update the version of express in package.json?