Node.js makes it easy to create a folder-based web server using JavaScript
- A browser (e.g., Chrome)
- A text editor (e.g., VS Code, or Notepad++, or Chrome)
- Folder-based
- Easy to write
- More practice with JavaScript
- Node.js non-blocking event loop supports many concurrent requests
- Install the lastest LTS version from the Node.js website
- Recommended for Windows Users: Add "Open PowerShell here as Administrator".
- Verify installation. Open Powershell in your working folder and run:
node -v
npm -v
Start your Server with either of these options. See the package.json for configuring npm scripts.
node server.js
npm start
- Open a web browser.
- Go to the URL: http://127.0.0.1:3001/ or http://localhost:3001/.
- Make changes to the server logic.
- Use CTRL-C, CTRL-C to stop your server.
- Restart the server to see your changes.
- Install nodemon globally - this is one of the rare packages to install globally.
- In your folder, open PowerShell here as Administrator, install and check the version.
npm install nodemon -g
nodemon -v
- Create a folder for server-side code.
- In the folder, create a file named server.js.
- In the folder, open PowerShell and run npm init to generate a package.json with app information.
- 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