Creating a Node.js project
In this guide, we will build a simple web server using Node.js and Express.
Last updated
In this guide, we will build a simple web server using Node.js and Express.
Last updated
Let's start by creating a folder to organise our project. In the file explorer section, tap on the create folder button to create a new folder. Hold the folder cell and rename the folder. You can now assign as it as the workpalce folder.
In this project, we will be using a third party npm module called Express
. Install it by running npm i express
in the terminal. You will now see a folder called node_modules
that contains the module we just installed. Another file created is package.json
, it stores the list of dependencies as well as other information of your project. You can learn more about npm here: https://docs.npmjs.com/cli/v7/configuring-npm/package-json
Creating a web server using Express is super simple. Create a new file index.js
and copy the following code.
Tap the run button on type node index.js
in the terminal to run the server. Launch Safari side-by-side and visit localhost:3000
. You now have yourself an Express server :).
To stop the server, press the stop (square) button located at the top right corner of the terminal tab.
A list of community-maintainted template projects including a React starter project can be found in the source control tab,.