Ask coding questions

← Back to all posts
[node.js] How to get a website that you would get with an HTML/CSS/JS repl?
Smart0ne (743)

How to get a website (in node.js) that you would get with an HTML/CSS/JS repl?

I looked at a few examples, but they were all too confusing. May someone please give explanations along with the code?

Answered by SixBeeps (5235) [earned 5 cycles]
View Answer
SixBeeps (5235)

Node.js does not do server hosting on its own. If you want to host a web server that serves HTML content, you need a library such as Express. I have a bit of boilerplate code that I use for a good majority of my Node web projects that uses it. You can give it a fork and remove the stuff that's in there (unless you plan on using sockets).

Highwayman (1483)

your loss. ¯\(ツ)
It's way less space and learning than express.

Highwayman (1483)

After writing all that I amend my statement:
it's way less learning for me. lol. gotta put things in perspective more often. @SixBeeps

IntellectualGuy (825)

Can you please explain further? Do you mean webview?

Smart0ne (743)

@IntellectualGuy In a HTML/CSS/JS repl, there's the console and a preview of the web page. However, in a node.js repl, there's only a consol. How would I get the preview, for node.js?

IntellectualGuy (825)

@Smart0ne Ah you have to host a server that shows you the HTML content, I have a template over here. Fork it if you want.