-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIntroduction.txt
42 lines (29 loc) · 1.64 KB
/
Introduction.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
1. Node.js is an open source server environment.
2. Node.js allows you to run JavaScript on the server.
3. Download Node.js from the official Node.js web site: https://nodejs.org and istall it.
******* Node.js uses asynchronous programming! *******
A common task for a web server can be to open a file on the server and return the content to the client.
=> Here is how PHP or ASP handles a file request:
1. Sends the task to the computer's file system.
2. Waits while the file system opens and reads the file.
3. Returns the content to the client.
4. Ready to handle the next request.
=> Here is how Node.js handles a file request:
1. Sends the task to the computer's file system.
2. Ready to handle the next request.
3. When the file system has opened and read the file, the server returns the content to the client.
4. Node.js eliminates the waiting, and simply continues with the next request.
Node.js runs single-threaded, non-blocking, asynchronous programming, which is very memory efficient.
=> What Can Node.js Do?
Node.js can generate dynamic page content
Node.js can create, open, read, write, delete, and close files on the server
Node.js can collect form data
Node.js can add, delete, modify data in your database
=> To run your node.js server use node myfirst.js
=> To run automatically start and stop a node js server follow this steps-
1. first install nodemon (need administration)
sudo npm i -g nodemon (for mac)
2. then use nodemon instead of node. i.e - nodemon myfirst.js
=> To connect with Database-
1. first install mysql module
sudo npm install mysql2 (for mac)