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 Build a Simple Dynamic Site with Node.js Creating a Simple Server in Node.js Preparing & Planning

Maurice Tafolla- Cunningham
Maurice Tafolla- Cunningham
7,708 Points

The preview option is not working for me in this exercise.

Okay so when prompted by Andrew to preview the index.html file in this exercise the "preview" button does something different from what I've experienced in all the other exercises. So when you click on "preview" a menu appears with this list:

  • Port 3000
  • Port 4567
  • Port 8000
  • Port 8080
  • Port 9292

I clicked on them all and I am taken to a page with this message:

Workspace Unavailable This is a preview link for a Treehouse Workspace that is not currently active. If you are the workspace owner, you can launch it again via the Treehouse site.

I'm not sure if this is limited to this instance of workspace, because I'm definitely partaking in an active session, and when I tried to preview another exercise it worked fine with no menu.

Treehouse might want to check into this.


3 Answers

Steve Brewer
Steve Brewer
15,030 Points

In video 4 of the next module (Creating a simple server) he'll explain how to do this, but he says copy the text from the nodejs.org homepage, but at the time I'm writing it's no longer there. But you can paste the code below into app.js:

var http = require("http");
http.createServer(function (request, response) {
 response.writeHead(200, {'Content-Type': 'text/plain'});
  response.end('Hello World\n');
console.log('Server running publicly');

Then run this in the console to get it working:

node app.js
Nathan Heffley
Nathan Heffley
19,878 Points

In the default workspace there is no server created yet. In one of the later episodes Andrew will show you how to make the Node.js app accessible through a browser and then you will be able to use the Preview button to see it.

Tom Dowling
Tom Dowling
5,584 Points

The Documentation isn't on the node.js.org homepage anymore but can be found on /about. https://nodejs.org/en/about/