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 Express Basics Parameters, Query Strings, and Modularizing Routes Modular Routes

Why can you do require('./routes/cards') and not require('./routes/cards.js')?

Do you never need the file extension?

1 Answer

Leopold Lucas
Leopold Lucas
17,236 Points

I think this is because it assumes that is a javascript file by default

Neil McPartlin
Neil McPartlin
14,662 Points

Agreed. And if you try require('./routes/cards.js'), this does work too but the extension just isn't needed.