Up and Running With NodeJS Express App In A Minute (2022)
Tags: javascript, webdev, beginners, programming
Published: 2022-05-30 11:23:40

---
canonical_url: https://softauthor.com/create-nodejs-express-app-faster/
---

In this Nodejs tutorial, you’re going to learn how to learn how to get up and running with nodejs app in a minutes.

Let’s get started.

- [Install Node.js & NPM](https://softauthor.com/create-nodejs-express-app-faster/#Install-nodejs-npm)
- [Initialize Your Project](https://softauthor.com/create-nodejs-express-app-faster/#initialize-nodejs-project)
- [Install Express](https://softauthor.com/create-nodejs-express-app-faster/#install-nodejs-express)
- [Install Nodemon](https://softauthor.com/create-nodejs-express-app-faster/#Install-nodejs-nodemon)
- [Create Index.js File](https://softauthor.com/create-nodejs-express-app-faster/#nodejs-indexjs-server-file)
- [Run Nodejs App](https://softauthor.com/create-nodejs-express-app-faster/#run-nodejs-app)

###Install Node.js & NPM
First make sure you install node and npm in your computer if you haven’t already.

Go to [nodejs.org](https://nodejs.org/en/) and download the LTS version of it in your computer.

![alt text](https://softauthor.com/wp-content/uploads/2022/05/Up-and-Running-WIth-Node.js-Node.js-home-page-1024x601.png)

Once its downloaded, double click to complete the installation process.

At this stage you’ve successfully installed Node as well as NPM (Node Package Manager).

To verify that, open up the Terminal or Command prompt from you computer and run the following commands:

```JavaScript
node -v
npm -v
```

###Initialize Your Project
Create a project folder in your computer and open it up in your favourite editor. I prefer visual studio as it comes with Terminal.

Then open up the Terminal Window, make sure you’re in the project directory, and run the following command which will initialize our project by creating a package.json file inside your project folder.

```JavaScript
npm init -y
```

###Install Express
The next step is to install [express](https://expressjs.com/), which is one of the most popular Node.js web application frameworks, so that we don’t have to get started from scratch.

To install express:

```JavaScript
npm I express
```

Once it’s installed successfully, you can see a folder called “node_modules” and a file called “package-lock.json” added to the project folder.

You can also check for the installed npm packages inside package.json under dependencies object.

![alt text](https://softauthor.com/wp-content/uploads/2022/05/Up-and-Running-WIth-Node.js-Express-installed--768x612.png)

###Install Nodemon
Nodemon is one of the npm packages that will help us to run the app without restarting the server every single time when we make a change in our project.

To install nodemon, run the following command:

```JavaScript
npm install nodemon
```

Then go to package.json and replace the property inside the scripts from:

```JavaScript
“Test”: “echo \”Err”
```

to:

```JavaScript
"devStart" : "nodemon index.js"
```

###Create Index.js file
Inside the project, create an index.js file, in there, import express at the top and create an express server and store it in a constant called app.

```JavaScript
const express = require('express');
const app = express();
```

Then, create a route for a home url which is “/” using HTTP get() request method.

```JavaScript
app.get("/", (req, res) => {
    res.send("I will be shown on the Browser");
    console.log("I will be shown on the Terminal");
});
```

Get() method takes two argument:

1. URL route, in this case, home url (“/”).
2. The callback arrow function which will have req and res as the parameters. This function will be invoked when a user goes to the home route.

Then, we can send some data to the browser using the response object by invoking send() method on it.

The text we’ve added as an argument to the send() method will be visible on the browser.

I’ve also console logged so that we can also see the text in our terminal/command line.

Finally, listen for port 3000.

```JavaScript
app.listen(3000);
```

###Run Node.js App
Let’s run the app by using the following command:

```JavaScript
nodemon
```

>Sometimes, you may get an error saying nodemon app crashed – waiting for file changes before starting.

>If you do get such an error, run the following command and restart nodemon

>_killall -9 node_

And that should fix the issue.

Once nodemon is running successfully, you can see the console.log message appears on the Terminal window.

![alt text](https://softauthor.com/wp-content/uploads/2022/05/Up-and-Running-WIth-Node.js-Nodemon-running-Terminal.png)

Open up the browser and navigate to the following URL:

```JavaScript
http://localhost:3000/
```

You can see the text appears on the browser.

![alt text](https://softauthor.com/wp-content/uploads/2022/05/Up-and-Running-WIth-Node.js-Nodejs-app-running-on-the-browser.png)