Nodejs Prac
Nodejs Prac
org
http://localhost:8080/
The date and time is currently: Mon Dec 02 2024 12:51:29 GMT+0530 (India
Standard Time)
"myfirstmodule.js"
exports.myDateTime = function () {
return Date();
};
var fs = require('fs');
Read files
Create files
Update files
Delete files
Rename files
Example:Read Files
demofile1.html
<html><body>
<h1>My Header</h1>
<p>My paragraph.</p>
</body></html>
"demo_readfile.js"
Node.js NPM
NPM to download the package you want.
C:\Users\Your Name>npm install upper-case
C:\Users\My Name\node_modules\upper-case
Using a Package
var uc = require('upper-case');
Create a Node.js file that will convert the output "Hello World!" into upper-case
letters:
STEP1 ON cmd
C:\Users\Your Name>node demo_uppercase.js
STEP2:ON BROWSER.
http://localhost:8080
OUTPUT:
HELLO WORLD!