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 trialDaniel Attiach
12,024 PointsUsing node.js on my localhost or treehouse workspace
Hello, I'm currently trying to make a small website where someone enters a username of a TreeHouse user in an input box and the site will display a line of information about the username.
I've ran an http server on my computer (Mac OS Sierra 10.12.6) and able to enter the website through 192.168.1.20:8080 which is my LAN address or 127.0.0.1:8080.
All I need is to be able to request modules from Node.js, such as 'https' and I keep getting an error in the console that require is not defined.
I know that Node.js is server-sided, which is why I used the http server, but I don't see what I'm doing wrong.
my app.js has a line to require https into a constant variable named https.
How do I get Node.js to work? I've uploaded my files to a workspace as well, and I can see that node is installed by using 'node -v' and I get the same problem there, too.
Thanks!
1 Answer
Steven Parker
231,269 PointsThere are different kinds of workspaces. The "Static" workspace provides a server for you, but in the "node.js" workspace your construct a server yourself using node.
It sounds like you may have published the JavaScript to the browser instead of executing it locally in a node-based server. But the good news is it sounds like your task can be accomplished without using node if it is just slightly altered.
To facilitate a more complete analysis, you can share your entire workspace if you make a snapshot and post the link to it here.
Daniel Attiach
12,024 PointsDaniel Attiach
12,024 PointsHere it is: https://w.trhou.se/dq05fviav7
Also, if we figure this out, I'd love it if you'd share some sort of guide that will help me understand how to work with Node.js on my local machine.
Thanks a lot!