Configured local web server with Node.js and http-server

  • Day: 2023-04-27
  • Time: 16:45 to 17:15
  • Project: Dev
  • Workspace: WP 2: Operational
  • Status: Completed
  • Priority: MEDIUM
  • Assignee: Matías Nehuen Iglesias
  • Tags: Node.Js, Http-Server, Local Server, Web Development, Nunjucks

Description

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.

Evidence

  • source_file=2023-04-27.sessions.jsonl, line_number=6, event_count=0, session_id=3d9eb586a49ddef87966d749ed0d074a38e2034742703a52c505240899cadb65
  • event_ids: []