Create Your first "hello world"
Creating a “hello world” Node.js Application
First, we will start by creating a directory for our project and then install some dependencies for our simple “Hello world” app using the command line.
**Install npm And Express Framework: **
Install npm and Express, which is a Node.js framework.
Then, initialize npm in our directory.
Copy or use the command below in your command line or terminal.
Above, npm
creates a package.json
that holds the dependencies of the app.
**Next, **install the Express framework dependency.
Codebase should look like this below:
Create a package.json file with the following content:
Create an app.js file with an HTTP server that will return Hello world.
Here is the code below :
Now, Save this file above, open your terminal, CLI (Command Line) to run the application
The app is now ready to launch:
It will show you on your terminal Server is running on port 5000
Go to your browser, copy and paste ** http://localhost:8080/
** in your browser to view it.
Here is a “Hello world” output on my browser :
Was this page helpful?