Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Creating Your First Node.js App | Introduction
Backend Development with Node.js and Express.js
course content

Зміст курсу

Backend Development with Node.js and Express.js

Backend Development with Node.js and Express.js

1. Introduction
2. Console Applications
3. Express.js Framework
4. Developing REST API

bookCreating Your First Node.js App

🚀 Let's take our first step into the world of Node.js by building a simple application. In this app, we'll generate a random number between 1 and 100 and display it on the screen. This exercise will help you get acquainted with creating and running a Node.js application on your local machine.

Note

We highly recommend working locally on your machine for the best learning experience.

Follow these steps 📝 to create your first Node.js app:

1. Create a New Project Directory

Begin by creating a new directory for your project. It must be the empty folder somewhere on your machine. Then open this folder in your code editor. We will use Visual Studio Code to demonstrate examples. You can select any that is convenient for you.

2. Create the app.js File

Inside the created directory, create a new file named app.js. This is where we'll write the code for our Node.js application.

3. Write the Application Code

This code uses JavaScript's built-in Math.random() function to generate a random number between 0 and 1. By multiplying it by 100 and adding 1, we ensure that the result falls between 1 and 100.

4. Run the Application

Open your terminal or command prompt and ensure you're still in the directory with the app.js file. Run the following command to execute the app.js file using Node.js:

You should see the output displaying the randomly generated number:

Real World Scenario 🌍

To further enhance your understanding, you can watch the following video, which demonstrates how to create and run the app in a real-world scenario:

Congratulations, you've successfully created and run your first Node.js application! 🎉 You've now taken your first step into the world of Node.js development.

What command must be run in the terminal to start the Node app?

What command must be run in the terminal to start the Node app?

Виберіть правильну відповідь

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 5
We're sorry to hear that something went wrong. What happened?
some-alt