How to Run Node.js With JavaScript Code
In this lesson, we'll use Node to run a simple JavaScript file on the server.
Running JavaScript with Node#
We have our Visual Studio Code Editor and our terminal available to us in our workspace.
To begin, we'll start with an empty folder labeled tinyhouse_v1/
in our editor workspace.
tinyhouse_v1/
tinyhouse_v1/
would be the directory where we build the app for the first part of our course. To get things started we're going to create a subfolder called server
within the tinyhouse_v1/
project that would host the server portion of our app. We'll also go ahead and have an index.js
file be created within this server
subfolder.
tinyhouse_v1/
server/
index.js
The node command#
For our very first attempt, we're going to see how we could use node
to run some JavaScript code and the first code we're going to write is a simple console.log
message.
This page is a preview of TinyHouse: A Fullstack React Masterclass with TypeScript and GraphQL