Giter Site home page Giter Site logo

node-server's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.