π 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-serverpackage. - Addressed the βnpm command not foundβ error, detailing the installation of npm and the
http-serverpackage. - Installed Node.js, including downloading from the official site and setting up environment variables on Linux.
- Configured the systemβs
PATHenvironment variable to include the Node.jsbindirectory, allowing command usage from any terminal location. - Ran the
http-serverpackage to serve a local website and configured it to serve.njkfiles 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.njkfiles 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-serverto enhance performance and security.