Monday, February 13, 2023

How To Install Node.js npm ( Creating Sample app ) on Oracle Linux 9

 Node.js is a JavaScript runtime for server-side programming. It allows developers to create scalable backend functionality using JavaScript, a language many are already familiar with from browser-based web development.
NPM is an acronym for Node Package Manager, which is the default package manager for Node.JS and the richest repository for Node.JS packages.
__________________________________________________________________________________________________________________________________
Server - Os:  Oracle Linux Server 9   64Bit      | IP -192.168.1.50        |Hostname - server.testbox.com
__________________________________________________________________________________________________________________________________
cat /etc/system-release ; dnf groupinstall "Development Tools" -y
curl -sL https://rpm.nodesource.com/setup_16.x | bash -
dnf install nodejs -y
node --version ; npm --version

Creating Sample app on Node.js
nano myapp.js
const http = require('http');

const hostname = '0.0.0.0';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World, running on NodeJS 1x');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

node myapp.js
http://127.0.0.1:3000
_________________________________________________________________________________________________________________________________


No comments:

Post a Comment