Skip to content

Node.js makes it easy to create a folder-based web server using JavaScript

Notifications You must be signed in to change notification settings

Valoderah/node-server

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

node-server

Node.js makes it easy to create a folder-based web server using JavaScript

Links

Requirements

  • A browser (e.g., Chrome)
  • A text editor (e.g., VS Code, or Notepad++, or Chrome)

Benefits

  • Folder-based
  • Easy to write
  • More practice with JavaScript
  • Node.js non-blocking event loop supports many concurrent requests

Install Node.js

  1. Install the lastest LTS version from the Node.js website
  2. Recommended for Windows Users: Add "Open PowerShell here as Administrator".
  3. Verify installation. Open Powershell in your working folder and run:
node -v
npm -v

Start your Server

Start your Server with either of these options. See the package.json for configuring npm scripts.

node server.js
npm start

Open a Browser Client

  1. Open a web browser.
  2. Go to the URL: http://127.0.0.1:3001/ or http://localhost:3001/.

Modify and Restart

  1. Make changes to the server logic.
  2. Use CTRL-C, CTRL-C to stop your server.
  3. Restart the server to see your changes.

Install Nodemon to enable live updates

  1. Install nodemon globally - this is one of the rare packages to install globally.
  2. In your folder, open PowerShell here as Administrator, install and check the version.
npm install nodemon -g
nodemon -v

Optional: Create a server from scratch

  1. Create a folder for server-side code.
  2. In the folder, create a file named server.js.
  3. In the folder, open PowerShell and run npm init to generate a package.json with app information.

Terms

  • Node.js platform
  • npm (Node package manager)
  • nodemon
  • npm install {packagename}
  • npm install -g {packagename}
  • npm start
  • package.json
  • localhost (127.0.0.1)
  • host
  • port
  • URL
  • web server
  • web service
  • web client
  • web request
  • web response

Reference

See Also

About

Node.js makes it easy to create a folder-based web server using JavaScript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%