CSA-301 Full Stack Development
[Link] Gaonkar, Ms. Vaibhavi Lamgaonkar
Goa Multi-Faculty College Dharbandora
Introduction to [Link]
Week 1 (7 Hours)
● Installation of [Link]
● Learn [Link] REPL
● Understanding Node js folder Structure
● Configuration of [Link] file in a new web application.
● Install Express
● Create a server using Express
● Installation of [Link]
● Learn [Link] REPL
[Link] comes with virtual environment called REPL (aka Node shell).
REPL stands for Read-Eval-Print-Loop.
Takes single expression as user input and returns the result back to
the console after execution.
➢ REPL Working:
❖ Read −Reads user's input, parses the input into JavaScript data-
structure, and stores in memory.
❖ Eval − Takes and evaluates the data structure.
❖ Print − Prints the result.
❖ Loop −Loops the above command until the user presses ctrl-c
twice
To launch the REPL (Node shell): open command prompt (in
Windows) or terminal (in Mac or UNIX/Linux) and type node as shown
below.
REPL session provides a convenient way to quickly test simple
JavaScript code. The command stays in idle mode and waits for us to
enter something in JS.
Example:
The first value, test, is the output. undefined which is the return value of
running [Link]().
➢ Node automatically prints the result of any line of JavaScript
code without the need to instruct it to do so.
Example:
➢ Use the tab to autocomplete.
Node REPL supports multiline instructions by taking user to multi-line
mode whenever required.
Example:
Terminal shows three dots (...) to express permission to continue with
code on next line.
➢ Can execute external files through node REPL
command prompt.
Example:
1. Write [Link]("Hello World"); in the external file.
2. Execute node filename on terminal
3. See output on terminal.
➢
● Understanding Node js folder Structure
➢ Create a new folder myapp, initialize a [Link] application, and configure
[Link] with project name "myapp".
● Configuration of [Link] file in a new web
application.
Steps to Configure [Link]
➢ Step 1: Initialize a [Link] Project
➢ use npm init -y to generate a default [Link] file.
• Install Express
Initial Node server setup: Prerequisite
➢ Create a directory to hold your application, and
make that as your working directory
>mkdir myapp
>cd myapp
➢ Use the npm init command to create a [Link]
file for your application.
>npm init
➢ Next, install Express.
Initial Node server setup:
➢ Install the Express framework globally using NPM
so that it can be used to create a web application
using node terminal.
>npm install express--save
➢ The above command saves the installation locally in the
node_modules directory and creates a directory express
inside node_modules
● Create a server using Express
Following is a basic express app example:
❖ It starts the server and listens on port 3000 for connection.
❖ This app responds with “Hello World!” for requests to the
homepage.
❖ For every other path it will respond with a 404 Not Found.
Output:
❖ Save the above code in a file named [Link] and run it
with the following command.
▪ node [Link]
❖ Open [Link] in any browser to see the
following result.