

Open a command prompt / command line window and enter the following: "npm install -g http-server"īrowse to your local website with a browser Load in the http module, set a port number (I chose 3001), and create the server with the createServer() method. Next, run the following command to install the ws library as a dependency.

Install the http-server globally on your machine using the node package manager (npm) command line tool, this will allow you to run a web server from anywhere on your computer. Before we get started on setting up an Express server, we will quickly set up an HTTP server with Node's built-in http module, to get an idea of how a simple server works. This creates a directory for our shiny new WebSocket Server to be built with NodeJS. If you haven’t installed Node yet, download the latest stable release of NodeJS from and install using all the default options. The web server runs on the http-server npm package, a simple zero-configuration http server for serving static files to the browser, it’s started from the command line and doesn’t require a server.js file. Install the http-server globally on your machine using the node package manager (npm) command line tool, this will allow you to run a web server from anywhere on your computer.
#Quick node server setup how to#
This is a quick post to show you how to setup a simple HTTP web server on your local machine using NodeJS. Run the above web server by writing node server.
