Node js Tutorial
Talk about javascript
1. What is node js
Node.js allows you to run JavaScript on the server
open source
Free
2. Node.js uses asynchronous programming!
Explain asynchronous programming with diagram
3. What can node js do->
Run on server so it will do all the things that other programming languages do
Db operations
File operations
Data processing
Much more
4. Installing node js:
Download node js from official
Install the setup buy doing next next and next
6. Vs code also required to write the code: go and download the vs code
7. Basic folder setup
8. Node Shell
10. Script using vs code:
Simple example
How to execute code using node js
11. Modules:
Libraries /Code already written
Http
Os
Fs
Express
Nodemon
url
Etc
require() function to import module
12. Creating simple server:
Example
13. Creating custom module:
Url module
For splitting query into readable parts
var q = url.parse(req.url, true).query;
File system module:
var fs = require('fs');
Read => readFile
fs.readFile('demofile1.html', function(err, data) {
});
Write
fs.writeFile('mynewfile3.txt', 'Hello content!', function (err) {
if (err) throw err;
console.log('Saved!');
});
Append
fs.appendFile('mynewfile1.txt', 'Hello content!', function (err) {
if (err) throw err;
console.log('Saved!');
});
Delete
fs.unlink('mynewfile2.txt', function (err) {
if (err) throw err;
console.log('File deleted!');
});
14. Node Package Manager(NPM)
Npm install package
Npm uninstall package
var uc = require('upper-case');
Nodemon
Express
Much more
15. Email Sender App
File Uploader