πŸ“… 2023-04-27 β€” Session: Configured local web server with Node.js and http-server

πŸ•’ 16:45–17:15
🏷️ Labels: Node.Js, Http-Server, Local Server, Web Development, Nunjucks
πŸ“‚ Project: Dev
⭐ Priority: MEDIUM

Session Goal

The primary goal of this session was to set up a local web server using Node.js and the http-server package to serve and view local website files, specifically focusing on .njk files in an 11ty static site generator project.

Key Activities

  • Developed a Nunjucks template for generating an XML sitemap within an 11ty project, including configuration and example code.
  • Provided a step-by-step guide to set up a local web server using Node.js and the http-server package.
  • Addressed the β€˜npm command not found’ error, detailing the installation of npm and the http-server package.
  • Installed Node.js, including downloading from the official site and setting up environment variables on Linux.
  • Configured the system’s PATH environment variable to include the Node.js bin directory, allowing command usage from any terminal location.
  • Ran the http-server package to serve a local website and configured it to serve .njk files correctly.
  • Troubleshot server access issues by providing correct URL usage and browser cache clearing advice.

Achievements

  • Successfully set up a local web server environment with Node.js and http-server, enabling the serving and viewing of .njk files in a browser.
  • Resolved common installation and configuration issues, ensuring smooth operation of the local server.

Pending Tasks

  • Further testing of the server configuration to ensure all file types are served correctly and efficiently.
  • Explore additional configuration options for http-server to enhance performance and security.