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 Creating a Simple Server

Piotr Manczak
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Piotr Manczak
Front End Web Development Techdegree Graduate 29,277 Points

server setup from nodejs.org not working in console

when a pasted a code from the nodejs.org for setting up a server it does not work in workspaces enviroment, therefore I cannot carry on with this course. Can someone help with this please. Maybe instead of the code from nodejs.org i can use different one or it needs to be modify somehow?

3 Answers

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Treehouse Project Reviewer

Hi Piotr Manczak ,

When I opened up a Workspace for this video this code was already within my app.js file, was it not in yours?

var http = require('http');
http.createServer(function (request, response) {
  response.writeHead(200, {'Content-Type': 'text/plain'});
  setInterval(function(){
    response.write(new Date() + "\n");
  }, 1000);
  response.end('Hello World\n');
}).listen(3000);
console.log('Server running at http://<workspace-url>/');

This worked just fine for me. When it's running, after running node app.js in the console, you can click the preview (eye) button up top and select port:3000.

When I copy/pasted the current code on the node.js website I indeed got an error regarding the import line they provide now.

I would just use the code above that was provided to continue along with the course and you should be just fine 👍

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Treehouse Project Reviewer

If you're still experiencing problems, can you provide a snapshot link to your workspace along with the commands you're trying? That will help us understand how to get you going again 😃