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

How to run nodejs code in the browser instead of command line

Hey, need some help please.

How to run nodejs code that just runs over some JSON data and prints it out, in the browser? I know in the command line, we just enter node nameOfFile.js , but how can I run this in the browser, so that I could add CSS to it to play around with it etc.?

Thanks

2 Answers

Hey Tom, I am going to try to answer your question. Node does blur some lines. However, JavaScript is running in the browser that allows you to code interactions or manipulate aspects of your HTML page. NodeJS code though is run on a server which sends and receives data from a web page/site. What this means...

If you want to manipulate data then display that data in a page would require you to have NodeJS code send the information to a page which is then manipulated and displayed using client-side services, such as HTML, CSS, and JavaScript. I know that does not necessarily directly address your question, but I hope that helps resolve some of the confusion about Node versus client-side javascript. Happy Coding!

up