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 trialAlex Lumierre
11,010 PointsI cannot preview my web from workspace.
I am currently learning node.js, however I cannot preview my workspace (i.e. there is a lot of port option there). Regarding this, which port should I use? How to fix the workspace?
3 Answers
Iain Simmons
Treehouse Moderator 32,305 PointsSo first up, because this is a Node app (or Node HTTP Server), you need to make sure the server is running first.
Andrew says the following:
So, if we do show console and then
node app.js
, we can see the server's running at the workspace URL, and when we go to port 3000, it goeshello world
.
Make sure that the node app.js
is run in the console first, and use port 3000 for the preview.
slorrain
6,538 PointsSame problem!
slorrain
6,538 PointsFinally, it worked for me. Here is my initial code (in app.js):
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, { 'Content-Type': 'text/plain' });
response.end('Hello World\n');
}).listen(3000);
console.log("server running");
Gabriel Ward
20,222 PointsGabriel Ward
20,222 PointsHi Iain,
I have got my server running in the console. I'm using port 3000. When I go to preview the workspace, it says it's unavailable. Do you have any advice on what the problem might be?
Iain Simmons
Treehouse Moderator 32,305 PointsIain Simmons
Treehouse Moderator 32,305 PointsHi Gabriel Ward, can you please share a Snapshot of your Workspace so we can see the code?