Skip to content
  • About Us
  • Contact Us
  • Privacy Policy
  • Terms & Conditions
  • Site Map

XpertPhp

Expertphp Is The Best Tutorial For Beginners

  • Home
  • Javascript
    • Jquery
    • React JS
    • Angularjs
    • Angular
    • Nodejs
  • Codeigniter
  • Laravel
  • Contact Us
  • About Us
  • Live Demos

Home » Nodejs » Hello world application using nodejs and express

Hello World Application Using Nodejs And Express

Hello world application using nodejs and express

Posted on November 2, 2019August 23, 2020 By XpertPhp 2 Comments on Hello world application using nodejs and express

In this article, we will learn how to create a hello world simple node js application in our application using node js and express. Nodejs is open source framework it used the javascript server and it is run on different os like as Windows, Linux, Unix, and Mac, etc. so first we will check the node is install or no in our system, if not in our system, then after we will go to follow below Url and install node js.

Read Also: How to install and download nodejs and npm for window os

Let’s go and follow the below step for how to display hello world in our application using node js and exress.js.

Step 1: Create the Application Directory.

First, we will open the command prompt and create the application directory. for this, you can follow the below command.

PHP
1
2
mkdir myapp
cd myapp

Step 2: Create an application using npm init

The “npm init” command through we can create a new package.json file in our application directory. when we build a new app at that time we use this command. Node.js will need to have a package.json file because includes the application related packages and application data.

Here below command helps to initialization our application.

PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
npm init
 
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
 
See `npm help json` for definitive documentation on these fields
and exactly what they do.
 
Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.
 
Press ^C at any time to quit.
package name: (myapp) myapp
version: (1.0.0)
description: myapp
entry point: (index.js)
test command:
git repository:
keywords:
author:
license: (ISC)
About to write to E:\test_mac\myapp\package.json:
 
{
  "name": "myapp",
  "version": "1.0.0",
  "description": "myapp",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}
 
Is this OK? (yes) yes

Step 3: Install Express Package

Expess.js is a free and open-source framework and it’s a web application framework for Node.js. we can manage routes, create restful API, handle the request and response, and also create MVC structure using the express.js. Npm stands for the node package manager. npm, help to install node packages and manage the types of dependencies.

Here below command help to install express package.

PHP
1
npm install express --save

Step 4: Create New File and Save

First, we will make a new file and paste follow the below code in our file and save as app.js.

PHP
1
2
3
4
5
6
7
8
var express = require('express');
var app = express();
app.get('/', function (req, res) {
  res.send('Hello World!');
});
app.listen(3000, function () {
  console.log('application listening on port 3000!');
});

Step 5: Run Our Application

Finally, We will run our application using the below command.

PHP
1
node app.js

Please follow and like us:
error
fb-share-icon
Tweet
fb-share-icon

Recommended Posts:

  • node js crud operations example using express with mysql
  • Node js Session Management Using Express Session
  • How to Render HTML File in Node JS Express
  • How to Generate QR Code in Node JS Application
  • Node JS Axios HTTP PUT Request Example
Nodejs Tags:nodejs, nodejs express example, nodejs from scratch, nodejs install

Post navigation

Previous Post: Laravel 6 Image Upload tutorial example
Next Post: Laravel 6 Pagination Example Tutorial

Latest Posts

  • Laravel Check If Foreach is Empty Example
  • Laravel Check Array Empty in Blade
  • PHP Datatables CRUD Example
  • How to Convert Date and Time from one timezone to another in php
  • how to get current date and time in php
  • Drag and Drop Reorder Items with jQuery, PHP & MySQL
  • Laravel 9 Toastr Notifications Example Tutorial
  • Laravel 9 CRUD Operation Example Using Google Firebase
  • Laravel 9 CKeditor Image Upload With Example
  • Laravel 9 Summernote Image Upload With Example

Tools

  • Compound Interest Calculator
  • Hex to RGB Color Converter
  • Pinterest Video Downloader
  • Birthday Calculator
  • Convert JSON to PHP Array Online
  • JavaScript Minifier
  • CSS Beautifier
  • CSS Minifier
  • JSON Beautifier
  • JSON Minifier

Categories

  • Ajax
  • Angular
  • Angularjs
  • Bootstrap
  • Codeigniter
  • Css
  • Htaccess
  • Javascript
  • Jquery
  • Laravel
  • MongoDB
  • MySql
  • Nodejs
  • Php
  • React JS
  • Shopify Api
  • Ubuntu

Tags

angular 10 tutorial angular 11 ci tutorial codeigniter 4 image upload Codeigniter 4 Tutorial codeigniter tutorial CodeIgniter tutorial for beginners codeigniter with mysql crud operation eloquent relationships file upload File Validation form validation Image Upload jQuery Ajax Form Handling jquery tricks jquery tutorial laravel 6 Laravel 6 Eloquent Laravel 6 Model laravel 6 relationship laravel 6 relationship eloquent Laravel 6 Routing laravel 7 Laravel 7 Eloquent laravel 7 routing laravel 7 tutorial Laravel 8 laravel 8 example laravel 8 tutorial laravel 9 example laravel 9 tutorial Laravel Framework laravel from scratch Laravel Socialite laravel social login nodejs pagination payment gateway php with mysql react js tutorial rewrite rule send mail validation wysiwyg editor

Copyright © 2018 - 2022,

All Rights Reserved Powered by XpertPhp.com