What npm command do you use to install the http-server package globally?
📦 Node.js-> Command Line
✨ The Prompt Phrase
npm install http-server -g
💻 Code Preview
📦 All-in-One Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>npm install http-server -g - Interactive Tutorial</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700;800&family=Fira+Code:wght@400;600&display=swap');
:root {
--primary: #667eea;
--secondary: #764ba2;
--accent: #f093fb;
--success: #4ade80;
--warning: #fbbf24;
--danger: #f87171;
--info: #3b82f6;
--dark: #1a1a2e;
--darker: #0f0f1e;
--light: #eaeaea;
--glass: rgba(255, 255, 255, 0.1);
--glass-border: rgba(255, 255, 255, 0.2);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
scroll-behavior: smooth;
}
body {
font-family: 'Poppins', sans-serif;
background: linear-gradient(135deg, var(--dark) 0%, var(--darker) 100%);
color: var(--light);
line-height: 1.6;
overflow-x: hidden;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
/* Progress Bar */
.progress-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 5px;
background: rgba(0, 0, 0, 0.3);
z-index: 1000;
}
.progress-bar {
height: 100%;
background: linear-gradient(90deg, var(--primary), var(--accent));
width: 0%;
transition: width 0.3s ease;
box-shadow: 0 0 10px var(--accent);
}
/* Hero Section */
.hero {
text-align: center;
padding: 100px 20px 80px;
position: relative;
z-index: 1;
}
.hero::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
opacity: 0.15;
animation: rotate 30s linear infinite;
}
@keyframes rotate {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.hero-badge {
display: inline-block;
padding: 8px 20px;
background: var(--glass);
backdrop-filter: blur(10px);
border: 2px solid var(--glass-border);
border-radius: 50px;
font-size: 0.9rem;
margin-bottom: 20px;
animation: fadeInDown 1s ease;
}
.hero h1 {
font-size: clamp(2rem, 5vw, 3.5rem);
font-weight: 800;
background: linear-gradient(135deg, var(--primary), var(--accent));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 20px;
animation: fadeInDown 1s ease 0.2s backwards;
line-height: 1.2;
}
.hero-subtitle {
font-size: clamp(1rem, 2vw, 1.3rem);
opacity: 0.8;
margin-bottom: 40px;
animation: fadeInUp 1s ease 0.4s backwards;
}
.command-box {
background: var(--glass);
backdrop-filter: blur(10px);
border: 2px solid var(--glass-border);
border-radius: 20px;
padding: 30px;
margin: 40px auto;
max-width: 700px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
animation: fadeIn 1s ease 0.6s backwards;
position: relative;
}
.command-box::before {
content: '💻';
position: absolute;
top: 20px;
right: 20px;
font-size: 2rem;
opacity: 0.3;
}
.command-box code {
font-family: 'Fira Code', monospace;
font-size: clamp(1.2rem, 3vw, 1.8rem);
color: var(--accent);
display: block;
padding: 20px;
background: rgba(0, 0, 0, 0.3);
border-radius: 10px;
border-left: 4px solid var(--primary);
position: relative;
}
.copy-btn {
position: absolute;
top: 10px;
right: 10px;
padding: 8px 16px;
background: var(--primary);
border: none;
border-radius: 8px;
color: white;
cursor: pointer;
font-weight: 600;
font-size: 0.85rem;
transition: all 0.3s ease;
}
.copy-btn:hover {
background: var(--accent);
transform: scale(1.05);
}
.copy-btn.copied {
background: var(--success);
}
/* Section Styles */
.section {
background: var(--glass);
backdrop-filter: blur(10px);
border: 1px solid var(--glass-border);
border-radius: 20px;
padding: 40px;
margin: 40px 0;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
animation: fadeInUp 0.8s ease;
position: relative;
z-index: 1;
}
.section h2 {
font-size: clamp(1.8rem, 4vw, 2.5rem);
margin-bottom: 25px;
background: linear-gradient(135deg, var(--primary), var(--accent));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
display: flex;
align-items: center;
gap: 15px;
flex-wrap: wrap;
}
.section p {
font-size: clamp(1rem, 2vw, 1.1rem);
margin-bottom: 15px;
opacity: 0.9;
line-height: 1.8;
}
/* Accordion */
.accordion {
margin: 20px 0;
}
.accordion-item {
background: rgba(102, 126, 234, 0.1);
border: 2px solid var(--primary);
border-radius: 15px;
margin: 15px 0;
overflow: hidden;
transition: all 0.3s ease;
}
.accordion-header {
padding: 20px;
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
font-weight: 600;
font-size: 1.1rem;
transition: background 0.3s ease;
}
.accordion-header:hover {
background: rgba(102, 126, 234, 0.2);
}
.accordion-icon {
transition: transform 0.3s ease;
font-size: 1.5rem;
}
.accordion-item.active .accordion-icon {
transform: rotate(180deg);
}
.accordion-content {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease;
padding: 0 20px;
}
.accordion-item.active .accordion-content {
max-height: 1000px;
padding: 20px;
}
/* Step Cards */
.steps-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
margin: 30px 0;
}
.step-card {
background: rgba(102, 126, 234, 0.1);
border: 2px solid var(--primary);
border-radius: 15px;
padding: 25px;
transition: all 0.3s ease;
cursor: pointer;
position: relative;
overflow: hidden;
}
.step-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 40px rgba(102, 126, 234, 0.4);
border-color: var(--accent);
}
.step-number {
display: inline-flex;
align-items: center;
justify-content: center;
width: 50px;
height: 50px;
background: linear-gradient(135deg, var(--primary), var(--accent));
border-radius: 50%;
font-weight: 700;
font-size: 1.5rem;
margin-bottom: 15px;
}
/* Code Breakdown */
.code-breakdown {
background: rgba(0, 0, 0, 0.3);
border-radius: 15px;
padding: 30px;
margin: 25px 0;
}
.code-part {
display: flex;
align-items: start;
gap: 20px;
margin: 20px 0;
padding: 20px;
background: rgba(255, 255, 255, 0.05);
border-radius: 10px;
border-left: 4px solid var(--accent);
}
.code-part-label {
font-family: 'Fira Code', monospace;
color: var(--accent);
font-weight: 600;
min-width: 150px;
font-size: 1.1rem;
}
.code-part-desc {
flex: 1;
}
/* Tabs */
.tabs {
display: flex;
gap: 10px;
margin-bottom: 20px;
flex-wrap: wrap;
}
.tab-btn {
padding: 12px 24px;
background: rgba(255, 255, 255, 0.05);
border: 2px solid var(--glass-border);
border-radius: 10px;
color: var(--light);
cursor: pointer;
font-weight: 600;
transition: all 0.3s ease;
}
.tab-btn:hover {
background: rgba(255, 255, 255, 0.1);
border-color: var(--primary);
}
.tab-btn.active {
background: linear-gradient(135deg, var(--primary), var(--accent));
border-color: var(--accent);
}
.tab-content {
display: none;
animation: fadeIn 0.5s ease;
}
.tab-content.active {
display: block;
}
/* Quiz */
.quiz-container {
background: rgba(102, 126, 234, 0.1);
border-radius: 20px;
padding: 40px;
margin: 30px 0;
border: 2px solid var(--primary);
}
.quiz-question {
background: rgba(0, 0, 0, 0.3);
border-radius: 15px;
padding: 30px;
margin: 25px 0;
}
.quiz-question h4 {
color: var(--accent);
margin-bottom: 20px;
font-size: 1.2rem;
}
.quiz-option {
padding: 18px 24px;
background: rgba(255, 255, 255, 0.05);
border: 2px solid var(--glass-border);
border-radius: 12px;
cursor: pointer;
transition: all 0.3s ease;
margin: 10px 0;
}
.quiz-option:hover {
background: rgba(255, 255, 255, 0.1);
border-color: var(--primary);
transform: translateX(5px);
}
.quiz-option.correct {
background: rgba(74, 222, 128, 0.2);
border-color: var(--success);
animation: correctAnswer 0.5s ease;
}
.quiz-option.incorrect {
background: rgba(248, 113, 113, 0.2);
border-color: var(--danger);
animation: shake 0.5s ease;
}
@keyframes correctAnswer {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.05); }
}
@keyframes shake {
0%, 100% { transform: translateX(0); }
25% { transform: translateX(-10px); }
75% { transform: translateX(10px); }
}
.quiz-feedback {
margin-top: 15px;
padding: 15px;
border-radius: 10px;
font-weight: 600;
display: none;
}
.quiz-feedback.show {
display: block;
animation: fadeIn 0.5s ease;
}
.quiz-score {
text-align: center;
font-size: 1.5rem;
margin-top: 30px;
padding: 20px;
background: linear-gradient(135deg, var(--primary), var(--accent));
border-radius: 15px;
font-weight: 700;
}
/* Cards */
.tip-card {
background: rgba(74, 222, 128, 0.1);
border-left: 4px solid var(--success);
border-radius: 10px;
padding: 20px;
margin: 15px 0;
}
.mistake-card {
background: rgba(248, 113, 113, 0.1);
border-left: 4px solid var(--danger);
border-radius: 10px;
padding: 20px;
margin: 15px 0;
}
.info-card {
background: rgba(59, 130, 246, 0.1);
border-left: 4px solid var(--info);
border-radius: 10px;
padding: 20px;
margin: 15px 0;
}
/* Summary */
.summary-card {
background: linear-gradient(135deg, var(--primary), var(--secondary));
border-radius: 25px;
padding: 50px;
margin: 40px 0;
box-shadow: 0 15px 50px rgba(102, 126, 234, 0.4);
}
.summary-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 25px;
margin-top: 30px;
}
.summary-item {
background: rgba(255, 255, 255, 0.15);
backdrop-filter: blur(10px);
border-radius: 15px;
padding: 25px;
text-align: center;
}
.summary-item h4 {
color: white;
margin: 15px 0;
font-size: 1.1rem;
}
.summary-item p {
color: white;
opacity: 0.9;
font-size: 0.95rem;
}
/* Footer */
.footer {
text-align: center;
padding: 60px 20px 40px;
margin-top: 80px;
border-top: 2px solid var(--glass-border);
}
.badge {
display: inline-block;
padding: 8px 18px;
background: linear-gradient(135deg, var(--primary), var(--accent));
border-radius: 25px;
font-size: 0.9rem;
font-weight: 600;
margin: 5px;
}
/* Tooltip */
.tooltip {
position: relative;
display: inline-block;
border-bottom: 2px dotted var(--accent);
cursor: help;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 250px;
background: var(--darker);
color: var(--light);
text-align: center;
border-radius: 10px;
padding: 10px;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -125px;
opacity: 0;
transition: opacity 0.3s;
border: 2px solid var(--primary);
font-size: 0.9rem;
}
.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
/* Animations */
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeInDown {
from {
opacity: 0;
transform: translateY(-30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* Confetti */
.confetti {
position: fixed;
width: 10px;
height: 10px;
pointer-events: none;
z-index: 9999;
animation: confettiFall 3s ease-out forwards;
}
@keyframes confettiFall {
to {
transform: translateY(100vh) rotate(720deg);
opacity: 0;
}
}
/* Scroll Button */
.scroll-top {
position: fixed;
bottom: 30px;
right: 30px;
width: 50px;
height: 50px;
background: linear-gradient(135deg, var(--primary), var(--accent));
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
opacity: 0;
transition: all 0.3s ease;
z-index: 999;
font-size: 1.5rem;
}
.scroll-top.show {
opacity: 1;
}
.scroll-top:hover {
transform: scale(1.1);
}
/* Responsive */
@media (max-width: 768px) {
.hero {
padding: 80px 20px 60px;
}
.section {
padding: 25px;
}
.summary-card {
padding: 30px 20px;
}
.code-part {
flex-direction: column;
}
.code-part-label {
min-width: auto;
}
}
</style>
</head>
<body>
<!-- Progress Bar -->
<div class="progress-container">
<div class="progress-bar" id="progressBar"></div>
</div>
<!-- Scroll to Top -->
<div class="scroll-top" id="scrollTop" onclick="scrollToTop()">↑</div>
<div class="container">
<!-- Hero Section -->
<section class="hero">
<div class="hero-badge">🚀 NPM Global Package Installation</div>
<h1>Master the Command Line</h1>
<p class="hero-subtitle">Learn how to install packages globally with npm and unlock powerful development tools!</p>
<div class="command-box">
<code id="mainCommand">npm install http-server -g</code>
<button class="copy-btn" onclick="copyCommand()">📋 Copy</button>
</div>
</section>
<!-- What Is It Section -->
<section class="section">
<h2>🤔 What Is It?</h2>
<p>
This command is your gateway to installing the <span class="tooltip"><strong>http-server</strong><span class="tooltiptext">A simple, zero-configuration command-line HTTP server</span></span> package globally on your computer. Let's break down what that means:
</p>
<div class="info-card">
<h4 style="color: var(--info); margin-bottom: 10px;">📦 Package Installation</h4>
<p>You're installing a tool that lets you quickly spin up a web server from any folder on your computer - perfect for testing websites locally!</p>
</div>
<p>
The <strong>-g</strong> flag means "global" - this package will be available from anywhere in your terminal, not just in one project folder. Think of it as installing an app on your computer versus just downloading a file to one folder.
</p>
</section>
<!-- Why Use It Section -->
<section class="section">
<h2>🌟 Why Use It?</h2>
<div class="steps-container">
<div class="step-card">
<div class="step-number">⚡</div>
<h4>Lightning Fast</h4>
<p>Start a web server in seconds without complex configuration!</p>
</div>
<div class="step-card">
<div class="step-number">🌐</div>
<h4>Test Locally</h4>
<p>Preview your HTML/CSS/JS projects before deploying to production!</p>
</div>
<div class="step-card">
<div class="step-number">🔧</div>
<h4>No Setup Required</h4>
<p>Zero configuration needed - just run and go!</p>
</div>
<div class="step-card">
<div class="step-number">📱</div>
<h4>Mobile Testing</h4>
<p>Access your local server from any device on your network!</p>
</div>
</div>
</section>
<!-- How It Works Section -->
<section class="section">
<h2>⚙️ How Does It Work?</h2>
<p>Let's walk through the process step by step:</p>
<div class="accordion">
<div class="accordion-item">
<div class="accordion-header" onclick="toggleAccordion(this)">
<span>Step 1: Open Your Terminal</span>
<span class="accordion-icon">▼</span>
</div>
<div class="accordion-content">
<p><strong>Windows:</strong> Press Win + R, type "cmd" or "powershell"</p>
<p><strong>Mac:</strong> Press Cmd + Space, type "terminal"</p>
<p><strong>Linux:</strong> Press Ctrl + Alt + T</p>
</div>
</div>
<div class="accordion-item">
<div class="accordion-header" onclick="toggleAccordion(this)">
<span>Step 2: Type the Command</span>
<span class="accordion-icon">▼</span>
</div>
<div class="accordion-content">
<p>Copy and paste: <code style="background: rgba(0,0,0,0.3); padding: 5px 10px; border-radius: 5px;">npm install http-server -g</code></p>
<p>Press Enter and watch the magic happen! ✨</p>
</div>
</div>
<div class="accordion-item">
<div class="accordion-header" onclick="toggleAccordion(this)">
<span>Step 3: Wait for Installation</span>
<span class="accordion-icon">▼</span>
</div>
<div class="accordion-content">
<p>NPM will download and install http-server. You'll see progress messages in your terminal.</p>
<p>This usually takes 10-30 seconds depending on your internet speed.</p>
</div>
</div>
<div class="accordion-item">
<div class="accordion-header" onclick="toggleAccordion(this)">
<span>Step 4: Verify Installation</span>
<span class="accordion-icon">▼</span>
</div>
<div class="accordion-content">
<p>Type: <code style="background: rgba(0,0,0,0.3); padding: 5px 10px; border-radius: 5px;">http-server --version</code></p>
<p>If you see a version number, congratulations! 🎉 You're ready to go!</p>
</div>
</div>
</div>
</section>
<!-- Live Demo Section -->
<section class="section">
<h2>🎮 Interactive Demo</h2>
<p>See how http-server works in different scenarios:</p>
<div class="tabs">
<button class="tab-btn active" onclick="switchTab(0)">Basic Usage</button>
<button class="tab-btn" onclick="switchTab(1)">Custom Port</button>
<button class="tab-btn" onclick="switchTab(2)">With Options</button>
</div>
<div class="tab-content active" id="tab0">
<div class="code-breakdown">
<h4 style="color: var(--accent); margin-bottom: 20px;">Navigate to your project folder and run:</h4>
<div style="background: rgba(0,0,0,0.5); padding: 20px; border-radius: 10px; font-family: 'Fira Code', monospace;">
<div style="color: var(--success);">$ cd my-website</div>
<div style="color: var(--accent);">$ http-server</div>
<div style="color: var(--light); opacity: 0.7; margin-top: 10px;">Starting up http-server...</div>
<div style="color: var(--light); opacity: 0.7;">Available on:</div>
<div style="color: var(--info);"> http://127.0.0.1:8080</div>
</div>
<p style="margin-top: 20px;">Open your browser and visit <strong>http://localhost:8080</strong> to see your website! 🌐</p>
</div>
</div>
<div class="tab-content" id="tab1">
<div class="code-breakdown">
<h4 style="color: var(--accent); margin-bottom: 20px;">Run on a specific port:</h4>
<div style="background: rgba(0,0,0,0.5); padding: 20px; border-radius: 10px; font-family: 'Fira Code', monospace;">
<div style="color: var(--accent);">$ http-server -p 3000</div>
<div style="color: var(--light); opacity: 0.7; margin-top: 10px;">Starting up http-server...</div>
<div style="color: var(--info);"> http://127.0.0.1:3000</div>
</div>
<p style="margin-top: 20px;">Now your server runs on port 3000 instead of the default 8080! 🎯</p>
</div>
</div>
<div class="tab-content" id="tab2">
<div class="code-breakdown">
<h4 style="color: var(--accent); margin-bottom: 20px;">Advanced options:</h4>
<div style="background: rgba(0,0,0,0.5); padding: 20px; border-radius: 10px; font-family: 'Fira Code', monospace;">
<div style="color: var(--accent);">$ http-server -p 8080 -o -c-1</div>
</div>
<ul style="margin-top: 20px; line-height: 2;">
<li><strong>-p 8080</strong> - Set port to 8080</li>
<li><strong>-o</strong> - Open browser automatically</li>
<li><strong>-c-1</strong> - Disable caching (great for development!)</li>
</ul>
</div>
</div>
</section>
<!-- Code Breakdown Section -->
<section class="section">
<h2>📝 Command Breakdown</h2>
<p>Let's dissect each part of the command:</p>
<div class="code-breakdown">
<div class="code-part">
<div class="code-part-label">npm</div>
<div class="code-part-desc">
<h4 style="color: var(--accent); margin-bottom: 10px;">Node Package Manager</h4>
<p>The tool that manages JavaScript packages. It comes bundled with Node.js and is your gateway to thousands of useful tools!</p>
</div>
</div>
<div class="code-part">
<div class="code-part-label">install</div>
<div class="code-part-desc">
<h4 style="color: var(--accent); margin-bottom: 10px;">The Install Command</h4>
<p>Tells npm to download and install a package. You can also use the shorthand <code style="background: rgba(0,0,0,0.3); padding: 3px 8px; border-radius: 5px;">i</code> instead of "install".</p>
</div>
</div>
<div class="code-part">
<div class="code-part-label">http-server</div>
<div class="code-part-desc">
<h4 style="color: var(--accent); margin-bottom: 10px;">Package Name</h4>
<p>The specific package you want to install. In this case, a simple HTTP server that can serve static files from any directory.</p>
</div>
</div>
<div class="code-part">
<div class="code-part-label">-g</div>
<div class="code-part-desc">
<h4 style="color: var(--accent); margin-bottom: 10px;">Global Flag</h4>
<p>Installs the package globally, making it available as a command-line tool from anywhere on your system. Without this, it would only install in the current project folder.</p>
</div>
</div>
</div>
</section>
<!-- Common Mistakes Section -->
<section class="section">
<h2>⚠️ Common Mistakes</h2>
<div class="mistake-card">
<h4 style="color: var(--danger); margin-bottom: 10px;">❌ Forgetting the -g Flag</h4>
<p><strong>Wrong:</strong> <code style="background: rgba(0,0,0,0.3); padding: 3px 8px; border-radius: 5px;">npm install http-server</code></p>
<p><strong>Result:</strong> Package installs locally in current folder only, not available globally!</p>
</div>
<div class="mistake-card">
<h4 style="color: var(--danger); margin-bottom: 10px;">❌ Permission Errors</h4>
<p>On Mac/Linux, you might need to use <code style="background: rgba(0,0,0,0.3); padding: 3px 8px; border-radius: 5px;">sudo</code> for global installs:</p>
<p><code style="background: rgba(0,0,0,0.3); padding: 3px 8px; border-radius: 5px;">sudo npm install http-server -g</code></p>
<p><strong>Tip:</strong> Consider using <a href="https://github.com/nvm-sh/nvm" style="color: var(--accent);">nvm</a> to avoid permission issues!</p>
</div>
<div class="mistake-card">
<h4 style="color: var(--danger); margin-bottom: 10px;">❌ Node.js Not Installed</h4>
<p>NPM requires Node.js to be installed first. Download it from <a href="https://nodejs.org" style="color: var(--accent);">nodejs.org</a></p>
</div>
<div class="mistake-card">
<h4 style="color: var(--danger); margin-bottom: 10px;">❌ Typos in Package Name</h4>
<p><strong>Wrong:</strong> <code style="background: rgba(0,0,0,0.3); padding: 3px 8px; border-radius: 5px;">npm install httpserver -g</code> (missing hyphen)</p>
<p><strong>Right:</strong> <code style="background: rgba(0,0,0,0.3); padding: 3px 8px; border-radius: 5px;">npm install http-server -g</code></p>
</div>
</section>
<!-- Pro Tips Section -->
<section class="section">
<h2>🚀 Pro Tips</h2>
<div class="tip-card">
<h4 style="color: var(--success); margin-bottom: 10px;">💎 Use the Shorthand</h4>
<p>Save time by using: <code style="background: rgba(0,0,0,0.3); padding: 3px 8px; border-radius: 5px;">npm i http-server -g</code></p>
<p>"i" is short for "install" - works exactly the same!</p>
</div>
<div class="tip-card">
<h4 style="color: var(--success); margin-bottom: 10px;">💎 Check Installed Packages</h4>
<p>See all globally installed packages: <code style="background: rgba(0,0,0,0.3); padding: 3px 8px; border-radius: 5px;">npm list -g --depth=0</code></p>
</div>
<div class="tip-card">
<h4 style="color: var(--success); margin-bottom: 10px;">💎 Update Packages</h4>
<p>Keep http-server up to date: <code style="background: rgba(0,0,0,0.3); padding: 3px 8px; border-radius: 5px;">npm update http-server -g</code></p>
</div>
<div class="tip-card">
<h4 style="color: var(--success); margin-bottom: 10px;">💎 Uninstall When Needed</h4>
<p>Remove the package: <code style="background: rgba(0,0,0,0.3); padding: 3px 8px; border-radius: 5px;">npm uninstall http-server -g</code></p>
</div>
<div class="tip-card">
<h4 style="color: var(--success); margin-bottom: 10px;">💎 Create an Alias</h4>
<p>Make it even faster! Add to your shell config:</p>
<p><code style="background: rgba(0,0,0,0.3); padding: 3px 8px; border-radius: 5px;">alias serve="http-server"</code></p>
<p>Now just type <code style="background: rgba(0,0,0,0.3); padding: 3px 8px; border-radius: 5px;">serve</code> to start your server! 🎉</p>
</div>
</section>
<!-- Quiz Section -->
<section class="section">
<h2>🎯 Knowledge Check</h2>
<p>Test what you've learned! Answer these questions:</p>
<div class="quiz-container">
<div class="quiz-question">
<h4>Question 1: What does the -g flag do?</h4>
<div class="quiz-option" onclick="checkAnswer(this, false, 0)">A) Makes the installation go faster</div>
<div class="quiz-option" onclick="checkAnswer(this, true, 0)">B) Installs the package globally</div>
<div class="quiz-option" onclick="checkAnswer(this, false, 0)">C) Generates documentation</div>
<div class="quiz-option" onclick="checkAnswer(this, false, 0)">D) Groups packages together</div>
<div class="quiz-feedback" id="feedback0"></div>
</div>
<div class="quiz-question">
<h4>Question 2: What is http-server used for?</h4>
<div class="quiz-option" onclick="checkAnswer(this, false, 1)">A) Creating HTTP requests</div>
<div class="quiz-option" onclick="checkAnswer(this, true, 1)">B) Running a local web server</div>
<div class="quiz-option" onclick="checkAnswer(this, false, 1)">C) Managing server databases</div>
<div class="quiz-option" onclick="checkAnswer(this, false, 1)">D) Sending emails</div>
<div class="quiz-feedback" id="feedback1"></div>
</div>
<div class="quiz-question">
<h4>Question 3: What's the shorthand for "npm install"?</h4>
<div class="quiz-option" onclick="checkAnswer(this, false, 2)">A) npm in</div>
<div class="quiz-option" onclick="checkAnswer(this, true, 2)">B) npm i</div>
<div class="quiz-option" onclick="checkAnswer(this, false, 2)">C) npm get</div>
<div class="quiz-option" onclick="checkAnswer(this, false, 2)">D) npm add</div>
<div class="quiz-feedback" id="feedback2"></div>
</div>
<div class="quiz-score" id="quizScore" style="display: none;">
🎉 You scored <span id="scoreValue">0</span>/3! <span id="scoreMessage"></span>
</div>
</div>
</section>
<!-- Summary Card -->
<section class="summary-card">
<h2 style="color: white; text-align: center; margin-bottom: 40px;">📚 Quick Reference</h2>
<div class="summary-grid">
<div class="summary-item">
<div style="font-size: 3rem;">📦</div>
<h4>Command</h4>
<p>npm install http-server -g</p>
</div>
<div class="summary-item">
<div style="font-size: 3rem;">🌐</div>
<h4>Purpose</h4>
<p>Install a local web server globally</p>
</div>
<div class="summary-item">
<div style="font-size: 3rem;">⚡</div>
<h4>Usage</h4>
<p>Run "http-server" in any folder</p>
</div>
<div class="summary-item">
<div style="font-size: 3rem;">🎯</div>
<h4>Default Port</h4>
<p>http://localhost:8080</p>
</div>
</div>
</section>
<!-- Footer -->
<footer class="footer">
<h3 style="background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent;">🎉 Tutorial Complete!</h3>
<p style="margin: 20px 0;">You're now ready to use http-server like a pro!</p>
<div>
<div class="badge">📦 NPM</div>
<div class="badge">🌐 Web Server</div>
<div class="badge">💻 Command Line</div>
<div class="badge">🚀 Development Tools</div>
</div>
<p style="margin-top: 30px; opacity: 0.7;">
📖 Generated by <strong>AI Prompt Dictionary</strong>
</p>
<p style="font-size: 0.9rem; opacity: 0.6; margin-top: 10px;">
© 2026 Interactive Tutorial System
</p>
</footer>
</div>
<script>
// Progress Bar
window.addEventListener('scroll', () => {
const winScroll = document.body.scrollTop || document.documentElement.scrollTop;
const height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
const scrolled = (winScroll / height) * 100;
document.getElementById('progressBar').style.width = scrolled + '%';
});
// Scroll to Top
window.addEventListener('scroll', () => {
const scrollTop = document.getElementById('scrollTop');
if (window.scrollY > 300) {
scrollTop.classList.add('show');
} else {
scrollTop.classList.remove('show');
}
});
function scrollToTop() {
window.scrollTo({ top: 0, behavior: 'smooth' });
}
// Copy Command
function copyCommand() {
const command = document.getElementById('mainCommand').textContent;
navigator.clipboard.writeText(command).then(() => {
const btn = document.querySelector('.copy-btn');
btn.textContent = '✓ Copied!';
btn.classList.add('copied');
setTimeout(() => {
btn.textContent = '📋 Copy';
btn.classList.remove('copied');
}, 2000);
});
}
// Accordion
function toggleAccordion(header) {
const item = header.parentElement;
const wasActive = item.classList.contains('active');
document.querySelectorAll('.accordion-item').forEach(el => {
el.classList.remove('active');
});
if (!wasActive) {
item.classList.add('active');
}
}
// Tabs
function switchTab(index) {
document.querySelectorAll('.tab-btn').forEach((btn, i) => {
btn.classList.toggle('active', i === index);
});
document.querySelectorAll('.tab-content').forEach((content, i) => {
content.classList.toggle('active', i === index);
});
}
// Quiz
let quizScore = 0;
let questionsAnswered = 0;
function checkAnswer(element, isCorrect, questionIndex) {
const options = element.parentElement.querySelectorAll('.quiz-option');
options.forEach(opt => opt.style.pointerEvents = 'none');
const feedback = document.getElementById('feedback' + questionIndex);
if (isCorrect) {
element.classList.add('correct');
feedback.style.background = 'rgba(74, 222, 128, 0.2)';
feedback.style.color = 'var(--success)';
feedback.textContent = '🎉 Correct! Excellent work!';
quizScore++;
createConfetti();
} else {
element.classList.add('incorrect');
feedback.style.background = 'rgba(248, 113, 113, 0.2)';
feedback.style.color = 'var(--danger)';
feedback.textContent = '❌ Not quite. Review the material above!';
}
feedback.classList.add('show');
questionsAnswered++;
if (questionsAnswered === 3) {
setTimeout(showFinalScore, 1000);
}
}
function showFinalScore() {
const scoreDiv = document.getElementById('quizScore');
const scoreValue = document.getElementById('scoreValue');
const scoreMessage = document.getElementById('scoreMessage');
scoreValue.textContent = quizScore;
if (quizScore === 3) {
scoreMessage.textContent = 'Perfect! You\'re a master! 🏆';
createConfetti();
} else if (quizScore === 2) {
scoreMessage.textContent = 'Great job! Almost there! 🌟';
} else {
scoreMessage.textContent = 'Keep learning! You\'ll get it! 💪';
}
scoreDiv.style.display = 'block';
}
// Confetti Effect
function createConfetti() {
for (let i = 0; i < 50; i++) {
const confetti = document.createElement('div');
confetti.className = 'confetti';
confetti.style.left = Math.random() * window.innerWidth + 'px';
confetti.style.background = ['#667eea', '#f093fb', '#4ade80', '#fbbf24'][Math.floor(Math.random() * 4)];
confetti.style.animationDelay = Math.random() * 0.5 + 's';
document.body.appendChild(confetti);
setTimeout(() => confetti.remove(), 3000);
}
}
// Add entrance animations on scroll
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -100px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.animation = 'fadeInUp 0.8s ease forwards';
}
});
}, observerOptions);
document.querySelectorAll('.section').forEach(section => {
observer.observe(section);
});
</script>
</body>
</html>
Live Preview