To test the nodejs installed, run the following code into the terminal
>>node --version
If nodejs installed it will shows the version of the nodejs
We can check also using the following command.
>>node // it runs the nodejs code.
>>console.log("Welcome To nodejs");
Output:
To run the simple webpage in server with the nodejs run the following code
>>Open the text editor and past the following code and save it as index.js
var http = require("http");
var fs = require("fs");
var server = http.createServer(function (req, res) {
console.log('request was made: ' + req.url);
res.writeHead(200, {'Content-Type': 'text/html'});
var myReadStream = fs.createReadStream(__dirname + '/login.html', 'utf8');
myReadStream.pipe(res);
// Send the response body as "Hello World"
});
server.listen(8084, '127.0.0.1');
// Console will print the message
console.log('Server running at http://127.0.0.1:8084/');
Then create a file and past the following code and save it as login.html.
Our team has expertise across software and web development, WordPress, e-commerce, mobile applications, UI/UX, cloud and infrastructure, DevOps, CI/CD, API integration, security, testing, automation, and technical support. The team also works with AI-based software solutions, LLMs, AI workflows, AI agents, and intelligent application development to help businesses automate processes and build smarter digital solutions. We focus on developing, deploying, maintaining, and optimising secure, scalable, and reliable technology solutions while helping businesses adopt modern technologies and drive digital transformation.