Install all dependencies and then remove unused packages in two commands
๐ฆ Node.js-> Command Line
โจ The Prompt Phrase
npm install npm prune
๐ป 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>Install all dependencies and then remove unused packages in two commands - Interactive Tutorial</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700;900&family=Fira+Code:wght@400;500;600&display=swap" rel="stylesheet">
<style>
:root {
--bg-primary: #0a0e27;
--bg-secondary: #151932;
--bg-card: #1e2139;
--accent-purple: #a855f7;
--accent-blue: #3b82f6;
--accent-green: #10b981;
--accent-red: #ef4444;
--accent-yellow: #f59e0b;
--accent-pink: #ec4899;
--accent-cyan: #06b6d4;
--accent-teal: #14b8a6;
--text-primary: #f8fafc;
--text-secondary: #94a3b8;
--gradient-install: linear-gradient(135deg, #10b981 0%, #059669 100%);
--gradient-prune: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
--gradient-combo: linear-gradient(135deg, #10b981 0%, #3b82f6 50%, #ef4444 100%);
--shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Poppins', sans-serif;
background: var(--bg-primary);
color: var(--text-primary);
line-height: 1.6;
overflow-x: hidden;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.progress-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 5px;
background: var(--bg-secondary);
z-index: 1000;
}
.progress-bar {
height: 100%;
background: var(--gradient-combo);
width: 0%;
transition: width 0.3s ease;
}
.hero {
text-align: center;
padding: 100px 20px;
background: var(--gradient-combo);
position: relative;
overflow: hidden;
border-radius: 0 0 50px 50px;
}
.hero::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="2" fill="white" opacity="0.1"/></svg>');
animation: float 20s linear infinite;
}
@keyframes float {
from { transform: translateY(0); }
to { transform: translateY(-100px); }
}
.hero-content {
position: relative;
z-index: 1;
}
.combo-icon {
font-size: 5rem;
margin-bottom: 20px;
animation: comboSpin 4s ease-in-out infinite;
}
@keyframes comboSpin {
0%, 100% { transform: rotate(0deg) scale(1); }
25% { transform: rotate(10deg) scale(1.1); }
50% { transform: rotate(0deg) scale(1); }
75% { transform: rotate(-10deg) scale(1.1); }
}
.command-display {
display: inline-block;
background: rgba(0, 0, 0, 0.4);
padding: 25px 40px;
border-radius: 15px;
font-family: 'Fira Code', monospace;
font-size: 1.3rem;
margin: 30px 0;
border: 3px solid rgba(255, 255, 255, 0.3);
color: white;
font-weight: 600;
}
.command-line {
margin: 5px 0;
}
.hero h1 {
font-size: 3.5rem;
font-weight: 900;
margin-bottom: 20px;
color: white;
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
.hero p {
font-size: 1.4rem;
opacity: 0.95;
color: white;
}
.section {
margin: 60px 0;
}
.section-title {
font-size: 2.5rem;
margin-bottom: 30px;
background: var(--gradient-combo);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
display: inline-block;
font-weight: 700;
}
.card {
background: var(--bg-card);
border-radius: 20px;
padding: 40px;
margin: 30px 0;
box-shadow: var(--shadow);
border: 1px solid rgba(255, 255, 255, 0.05);
transition: transform 0.3s ease;
}
.card:hover {
transform: translateY(-5px);
}
.code-block {
background: #1e1e1e;
border-radius: 15px;
padding: 25px;
margin: 20px 0;
font-family: 'Fira Code', monospace;
position: relative;
}
.code-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
padding-bottom: 15px;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.terminal-dots {
display: flex;
gap: 6px;
}
.terminal-dot {
width: 12px;
height: 12px;
border-radius: 50%;
}
.dot-red { background: #ff5f56; }
.dot-yellow { background: #ffbd2e; }
.dot-green { background: #27c93f; }
.copy-btn {
background: var(--accent-purple);
color: white;
border: none;
padding: 8px 16px;
border-radius: 8px;
cursor: pointer;
font-size: 0.9rem;
transition: all 0.3s ease;
}
.copy-btn:hover {
background: var(--accent-blue);
transform: scale(1.05);
}
.copy-btn.copied {
background: var(--accent-green);
}
pre {
margin: 0;
overflow-x: auto;
}
code {
color: #e0e0e0;
font-size: 0.95rem;
line-height: 1.8;
}
.code-comment { color: #6a9955; }
.code-string { color: #ce9178; }
.code-keyword { color: #569cd6; }
.code-install { color: #10b981; font-weight: 600; }
.code-prune { color: #ef4444; font-weight: 600; }
.code-npm { color: #cb3837; font-weight: 600; }
.steps {
counter-reset: step-counter;
}
.step {
background: var(--bg-secondary);
border-radius: 15px;
padding: 30px;
margin: 20px 0;
position: relative;
padding-left: 100px;
transition: all 0.3s ease;
}
.step:hover {
background: var(--bg-card);
transform: translateX(10px);
}
.step::before {
counter-increment: step-counter;
content: counter(step-counter);
position: absolute;
left: 20px;
top: 50%;
transform: translateY(-50%);
width: 60px;
height: 60px;
background: var(--gradient-combo);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.8rem;
font-weight: 900;
color: white;
}
.step h3 {
color: var(--accent-teal);
margin-bottom: 10px;
font-size: 1.5rem;
}
.feature-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 25px;
margin: 30px 0;
}
.feature-card {
background: var(--bg-secondary);
padding: 30px;
border-radius: 15px;
text-align: center;
transition: all 0.3s ease;
border: 2px solid transparent;
}
.feature-card:hover {
border-color: var(--accent-teal);
transform: translateY(-10px);
}
.feature-icon {
font-size: 3.5rem;
margin-bottom: 15px;
}
.feature-title {
font-weight: 600;
color: var(--accent-teal);
margin-bottom: 10px;
font-size: 1.3rem;
}
.demo-container {
background: var(--bg-secondary);
border-radius: 20px;
padding: 40px;
margin: 30px 0;
}
.comparison-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin: 30px 0;
}
.comparison-card {
background: var(--bg-card);
padding: 30px;
border-radius: 15px;
border: 3px solid;
}
.install-card {
border-color: var(--accent-green);
}
.prune-card {
border-color: var(--accent-red);
}
.terminal {
background: #1e1e1e;
border-radius: 15px;
padding: 20px;
font-family: 'Fira Code', monospace;
min-height: 250px;
margin: 20px 0;
overflow-y: auto;
max-height: 500px;
}
.terminal-line {
margin: 10px 0;
}
.terminal-prompt {
color: var(--accent-green);
}
.demo-button {
background: var(--gradient-combo);
color: white;
border: none;
padding: 15px 40px;
border-radius: 50px;
font-size: 1.1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
display: inline-flex;
align-items: center;
gap: 10px;
margin: 10px;
}
.demo-button:hover {
transform: scale(1.05);
box-shadow: 0 10px 30px rgba(16, 185, 129, 0.4);
}
.tabs {
display: flex;
gap: 10px;
margin-bottom: 20px;
flex-wrap: wrap;
}
.tab {
padding: 12px 24px;
background: var(--bg-secondary);
border: none;
border-radius: 10px;
color: var(--text-primary);
cursor: pointer;
transition: all 0.3s ease;
font-size: 1rem;
}
.tab:hover {
background: var(--bg-card);
}
.tab.active {
background: var(--gradient-combo);
color: white;
}
.tab-content {
display: none;
}
.tab-content.active {
display: block;
}
.accordion-header {
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px;
background: var(--bg-secondary);
border-radius: 12px;
margin: 15px 0;
transition: all 0.3s ease;
}
.accordion-header:hover {
background: var(--bg-card);
}
.accordion-icon {
transition: transform 0.3s ease;
font-size: 1.2rem;
}
.accordion-icon.active {
transform: rotate(180deg);
}
.accordion-content {
max-height: 0;
overflow: hidden;
transition: max-height 0.3s ease;
}
.accordion-content.active {
max-height: 2000px;
}
.accordion-body {
padding: 20px;
background: var(--bg-secondary);
border-radius: 12px;
margin-top: 5px;
}
.tip, .warning, .success, .info {
padding: 20px;
border-radius: 10px;
margin: 20px 0;
}
.tip {
background: rgba(59, 130, 246, 0.1);
border-left: 4px solid var(--accent-blue);
}
.tip::before { content: '๐ก '; font-size: 1.5rem; }
.warning {
background: rgba(239, 68, 68, 0.1);
border-left: 4px solid var(--accent-red);
}
.warning::before { content: 'โ ๏ธ '; font-size: 1.5rem; }
.success {
background: rgba(16, 185, 129, 0.1);
border-left: 4px solid var(--accent-green);
}
.success::before { content: 'โ
'; font-size: 1.5rem; }
.info {
background: rgba(236, 72, 153, 0.1);
border-left: 4px solid var(--accent-pink);
}
.info::before { content: '๐ '; font-size: 1.5rem; }
.quiz-container {
background: var(--bg-card);
border-radius: 20px;
padding: 40px;
margin: 30px 0;
}
.quiz-question {
margin: 30px 0;
}
.quiz-question h3 {
color: var(--accent-purple);
margin-bottom: 20px;
font-size: 1.3rem;
}
.quiz-options {
display: flex;
flex-direction: column;
gap: 15px;
}
.quiz-option {
background: var(--bg-secondary);
padding: 20px;
border-radius: 12px;
cursor: pointer;
transition: all 0.3s ease;
border: 2px solid transparent;
}
.quiz-option:hover {
border-color: var(--accent-blue);
transform: translateX(10px);
}
.quiz-option.correct {
border-color: var(--accent-green);
background: rgba(16, 185, 129, 0.1);
}
.quiz-option.incorrect {
border-color: var(--accent-red);
background: rgba(239, 68, 68, 0.1);
}
.quiz-feedback {
margin-top: 15px;
padding: 15px;
border-radius: 10px;
display: none;
}
.quiz-feedback.show {
display: block;
}
.quiz-feedback.correct {
background: rgba(16, 185, 129, 0.1);
border-left: 4px solid var(--accent-green);
}
.quiz-feedback.incorrect {
background: rgba(239, 68, 68, 0.1);
border-left: 4px solid var(--accent-red);
}
.cheat-sheet {
background: var(--gradient-combo);
border-radius: 20px;
padding: 40px;
margin: 30px 0;
color: white;
}
.cheat-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 20px;
margin-top: 30px;
}
.cheat-item {
background: rgba(255, 255, 255, 0.15);
backdrop-filter: blur(10px);
padding: 20px;
border-radius: 15px;
border: 1px solid rgba(255, 255, 255, 0.2);
}
.cheat-item h4 {
color: white;
margin-bottom: 10px;
font-weight: 600;
}
.cheat-item code {
background: rgba(0, 0, 0, 0.3);
padding: 4px 8px;
border-radius: 5px;
font-size: 0.9rem;
color: white;
}
.highlight {
color: var(--accent-yellow);
font-weight: 600;
}
.footer {
text-align: center;
padding: 40px 20px;
background: var(--bg-secondary);
margin-top: 80px;
border-radius: 20px;
}
.footer p {
color: var(--text-secondary);
margin: 10px 0;
}
.badge {
display: inline-block;
padding: 6px 12px;
background: var(--gradient-combo);
border-radius: 20px;
font-size: 0.85rem;
font-weight: 600;
margin: 5px;
}
.confetti {
position: fixed;
width: 10px;
height: 10px;
background: var(--accent-green);
animation: confetti-fall 3s linear forwards;
z-index: 9999;
}
@keyframes confetti-fall {
to {
transform: translateY(100vh) rotate(360deg);
opacity: 0;
}
}
@media (max-width: 768px) {
.hero h1 { font-size: 2rem; }
.command-display { font-size: 1rem; padding: 15px 20px; }
.section-title { font-size: 1.8rem; }
.card { padding: 25px; }
.step { padding-left: 80px; }
.step::before { width: 50px; height: 50px; font-size: 1.5rem; }
.comparison-grid { grid-template-columns: 1fr; }
}
</style>
</head>
<body>
<div class="progress-container">
<div class="progress-bar" id="progressBar"></div>
</div>
<div class="hero">
<div class="hero-content">
<div class="combo-icon">๐</div>
<h1>Master npm install & prune!</h1>
<div class="command-display">
<div class="command-line">npm install</div>
<div class="command-line">npm prune</div>
</div>
<p>Install & Clean in Two Steps! ๐งน</p>
</div>
</div>
<div class="container">
<!-- What Is It -->
<section class="section">
<h2 class="section-title">๐ค What Are These Commands?</h2>
<div class="card">
<p style="font-size: 1.2rem; margin-bottom: 20px;">
This powerful combo <span class="highlight">installs all dependencies</span> and then <span class="highlight">removes unused packages</span> - it's like cleaning your room after unpacking! ๐ฆ๐งน
</p>
<p style="margin-bottom: 20px;">
Think of it as a two-step dance! ๐ First, <code>npm install</code> brings in all the packages your project needs (listed in package.json). Then, <code>npm prune</code> sweeps away any packages that aren't actually needed anymore. Together, they ensure your node_modules is perfectly clean and optimized!
</p>
<div class="comparison-grid">
<div class="comparison-card install-card">
<h3 style="color: var(--accent-green); margin-bottom: 15px;">๐ฅ npm install</h3>
<p><strong>What it does:</strong> Installs all dependencies from package.json</p>
<ul style="margin-left: 20px; margin-top: 10px; line-height: 2;">
<li>Reads package.json</li>
<li>Downloads packages</li>
<li>Creates node_modules</li>
<li>Generates package-lock.json</li>
</ul>
</div>
<div class="comparison-card prune-card">
<h3 style="color: var(--accent-red); margin-bottom: 15px;">๐๏ธ npm prune</h3>
<p><strong>What it does:</strong> Removes packages not in package.json</p>
<ul style="margin-left: 20px; margin-top: 10px; line-height: 2;">
<li>Checks node_modules</li>
<li>Compares with package.json</li>
<li>Deletes unused packages</li>
<li>Cleans up dependencies</li>
</ul>
</div>
</div>
<div class="success" style="margin-top: 20px;">
<strong>The Perfect Combo:</strong> Install everything you need, remove everything you don't!
</div>
</div>
</section>
<!-- Why Use It -->
<section class="section">
<h2 class="section-title">โจ Why Use This Combo?</h2>
<div class="card">
<div class="feature-grid">
<div class="feature-card">
<div class="feature-icon">๐งน</div>
<div class="feature-title">Clean Setup</div>
<p style="color: var(--text-secondary);">Fresh, optimized install!</p>
</div>
<div class="feature-card">
<div class="feature-icon">๐พ</div>
<div class="feature-title">Save Space</div>
<p style="color: var(--text-secondary);">Remove unused packages!</p>
</div>
<div class="feature-card">
<div class="feature-icon">๐</div>
<div class="feature-title">Security</div>
<p style="color: var(--text-secondary);">Fewer attack vectors!</p>
</div>
<div class="feature-card">
<div class="feature-icon">โก</div>
<div class="feature-title">Performance</div>
<p style="color: var(--text-secondary);">Faster builds!</p>
</div>
<div class="feature-card">
<div class="feature-icon">๐ฏ</div>
<div class="feature-title">Accuracy</div>
<p style="color: var(--text-secondary);">Only what you need!</p>
</div>
<div class="feature-card">
<div class="feature-icon">๐</div>
<div class="feature-title">Consistency</div>
<p style="color: var(--text-secondary);">Matches package.json!</p>
</div>
</div>
</div>
</section>
<!-- How It Works -->
<section class="section">
<h2 class="section-title">โ๏ธ How Does It Work?</h2>
<div class="card">
<div class="steps">
<div class="step">
<h3>Step 1: npm install Starts</h3>
<p>Reads package.json to see what dependencies are needed.</p>
</div>
<div class="step">
<h3>Step 2: Download Packages</h3>
<p>Downloads all listed dependencies from npm registry.</p>
</div>
<div class="step">
<h3>Step 3: Install Complete</h3>
<p>Creates/updates node_modules with all packages.</p>
</div>
<div class="step">
<h3>Step 4: npm prune Starts</h3>
<p>Scans node_modules for installed packages.</p>
</div>
<div class="step">
<h3>Step 5: Compare & Identify</h3>
<p>Finds packages not listed in package.json.</p>
</div>
<div class="step">
<h3>Step 6: Clean Up!</h3>
<p>Removes unused packages - perfectly clean! ๐</p>
</div>
</div>
</div>
</section>
<!-- Live Demo -->
<section class="section">
<h2 class="section-title">๐ฎ Interactive Demo</h2>
<div class="demo-container">
<div style="margin-bottom: 30px; text-align: center;">
<h4 style="margin-bottom: 15px;">See the Combo in Action! ๐</h4>
<button class="demo-button" onclick="simulateInstall()">
<span>๐ฅ</span>
<span>npm install</span>
</button>
<button class="demo-button" onclick="simulatePrune()">
<span>๐๏ธ</span>
<span>npm prune</span>
</button>
<button class="demo-button" onclick="simulateCombo()">
<span>๐</span>
<span>Full Combo</span>
</button>
</div>
<div class="terminal" id="terminal">
<div class="terminal-line">
<span class="terminal-prompt">$</span>
<span style="color: var(--text-secondary);"> Ready to install and clean...</span>
</div>
</div>
</div>
</section>
<!-- Code Breakdown -->
<section class="section">
<h2 class="section-title">๐ป Usage Examples</h2>
<div class="card">
<div class="tabs">
<button class="tab active" onclick="switchTab('basic')">Basic Usage</button>
<button class="tab" onclick="switchTab('options')">With Options</button>
<button class="tab" onclick="switchTab('scenarios')">Use Cases</button>
<button class="tab" onclick="switchTab('automation')">Automation</button>
</div>
<div id="basic" class="tab-content active">
<h3 style="color: var(--accent-pink); margin-bottom: 15px;">Basic Install & Prune</h3>
<div class="code-block">
<div class="code-header">
<div class="terminal-dots">
<div class="terminal-dot dot-red"></div>
<div class="terminal-dot dot-yellow"></div>
<div class="terminal-dot dot-green"></div>
</div>
<button class="copy-btn" onclick="copyCode('basic-code')">๐ Copy</button>
</div>
<pre><code id="basic-code"><span class="code-comment"># Step 1: Install all dependencies</span>
npm install
<span class="code-comment"># Installs everything from package.json</span>
<span class="code-comment"># Step 2: Remove unused packages</span>
npm prune
<span class="code-comment"># Removes packages not in package.json</span>
<span class="code-comment"># One-liner (run both commands)</span>
npm install && npm prune
<span class="code-comment"># What happens:</span>
<span class="code-comment"># 1. All dependencies installed โ
</span>
<span class="code-comment"># 2. Unused packages removed โ
</span>
<span class="code-comment"># 3. node_modules is clean โ
</span>
<span class="code-comment"># Alternative: use npm ci (clean install)</span>
npm ci
<span class="code-comment"># Does install + prune automatically!</span></code></pre>
</div>
<div class="success" style="margin-top: 15px;">
<strong>Result:</strong> Perfect, clean node_modules with only what you need!
</div>
</div>
<div id="options" class="tab-content">
<h3 style="color: var(--accent-pink); margin-bottom: 15px;">Advanced Options</h3>
<div class="code-block">
<div class="code-header">
<div class="terminal-dots">
<div class="terminal-dot dot-red"></div>
<div class="terminal-dot dot-yellow"></div>
<div class="terminal-dot dot-green"></div>
</div>
<button class="copy-btn" onclick="copyCode('options-code')">๐ Copy</button>
</div>
<pre><code id="options-code"><span class="code-comment"># Install production dependencies only</span>
npm install --production
npm prune --production
<span class="code-comment"># Removes devDependencies too</span>
<span class="code-comment"># Prune with dry-run (see what would be removed)</span>
npm prune --dry-run
<span class="code-comment"># Shows what would be deleted without actually deleting</span>
<span class="code-comment"># Install with specific registry</span>
npm install --registry=https://registry.npmjs.org
npm prune
<span class="code-comment"># Verbose output</span>
npm install --verbose
npm prune --verbose
<span class="code-comment"># See detailed information</span>
<span class="code-comment"># Clean install (deletes node_modules first)</span>
rm -rf node_modules
npm install
npm prune
<span class="code-comment"># Or use npm ci (recommended for CI/CD)</span>
npm ci
<span class="code-comment"># Removes node_modules, installs from lock file, and prunes</span></code></pre>
</div>
<div class="tip" style="margin-top: 15px;">
<strong>Pro Tip:</strong> Use <code>npm ci</code> in CI/CD - it's faster and does both steps automatically!
</div>
</div>
<div id="scenarios" class="tab-content">
<h3 style="color: var(--accent-pink); margin-bottom: 15px;">Common Scenarios</h3>
<div class="code-block">
<div class="code-header">
<div class="terminal-dots">
<div class="terminal-dot dot-red"></div>
<div class="terminal-dot dot-yellow"></div>
<div class="terminal-dot dot-green"></div>
</div>
<button class="copy-btn" onclick="copyCode('scenarios-code')">๐ Copy</button>
</div>
<pre><code id="scenarios-code"><span class="code-comment"># Scenario 1: After git pull</span>
git pull
npm install <span class="code-comment"># Get new dependencies</span>
npm prune <span class="code-comment"># Remove old ones</span>
<span class="code-comment"># Scenario 2: After manually editing package.json</span>
<span class="code-comment"># (removed some dependencies)</span>
npm install <span class="code-comment"># Update based on changes</span>
npm prune <span class="code-comment"># Clean up removed packages</span>
<span class="code-comment"># Scenario 3: Cleaning up after testing</span>
<span class="code-comment"># (installed packages with npm install [package])</span>
npm prune <span class="code-comment"># Remove packages not in package.json</span>
<span class="code-comment"># Scenario 4: Before deployment</span>
npm install --production
npm prune --production
<span class="code-comment"># Only production dependencies</span>
<span class="code-comment"># Scenario 5: Fresh start</span>
rm -rf node_modules package-lock.json
npm install
npm prune
<span class="code-comment"># Complete clean reinstall</span>
<span class="code-comment"># Scenario 6: Switching branches</span>
git checkout feature-branch
npm install && npm prune
<span class="code-comment"># Sync dependencies with branch</span></code></pre>
</div>
</div>
<div id="automation" class="tab-content">
<h3 style="color: var(--accent-pink); margin-bottom: 15px;">Automation Scripts</h3>
<div class="code-block">
<div class="code-header">
<div class="terminal-dots">
<div class="terminal-dot dot-red"></div>
<div class="terminal-dot dot-yellow"></div>
<div class="terminal-dot dot-green"></div>
</div>
<button class="copy-btn" onclick="copyCode('automation-code')">๐ Copy</button>
</div>
<pre><code id="automation-code"><span class="code-comment"># package.json scripts</span>
{
<span class="code-string">"scripts"</span>: {
<span class="code-string">"postinstall"</span>: <span class="code-string">"npm prune"</span>,
<span class="code-comment">// Automatically prune after install</span>
<span class="code-string">"clean-install"</span>: <span class="code-string">"npm install && npm prune"</span>,
<span class="code-comment">// Custom clean install command</span>
<span class="code-string">"fresh"</span>: <span class="code-string">"rm -rf node_modules && npm install && npm prune"</span>,
<span class="code-comment">// Complete fresh install</span>
<span class="code-string">"prod-install"</span>: <span class="code-string">"npm install --production && npm prune --production"</span>
<span class="code-comment">// Production-only install</span>
}
}
<span class="code-comment"># Shell script (setup.sh)</span>
#!/bin/bash
echo <span class="code-string">"๐ Installing dependencies..."</span>
npm install
echo <span class="code-string">"๐งน Cleaning up..."</span>
npm prune
echo <span class="code-string">"โ
Setup complete!"</span>
<span class="code-comment"># CI/CD (GitHub Actions)</span>
- name: Install dependencies
run: |
npm ci
<span class="code-comment"># npm ci does install + prune automatically</span>
<span class="code-comment"># Docker</span>
RUN npm install && npm prune --production</code></pre>
</div>
</div>
</div>
</section>
<!-- Common Mistakes -->
<section class="section">
<h2 class="section-title">โ Common Mistakes</h2>
<div class="card">
<div class="accordion">
<div class="accordion-item">
<div class="accordion-header" onclick="toggleAccordion(this)">
<span><strong>1. Forgetting to Prune</strong></span>
<span class="accordion-icon">โผ</span>
</div>
<div class="accordion-content">
<div class="accordion-body">
<div class="warning">
<strong>Problem:</strong> Running only <code>npm install</code> leaves old packages behind
</div>
<div class="success" style="margin-top: 15px;">
<strong>Solution:</strong> Always run <code>npm prune</code> after install, or use <code>npm ci</code>!
</div>
</div>
</div>
</div>
<div class="accordion-item">
<div class="accordion-header" onclick="toggleAccordion(this)">
<span><strong>2. Pruning Before Installing</strong></span>
<span class="accordion-icon">โผ</span>
</div>
<div class="accordion-content">
<div class="accordion-body">
<div class="warning">
<strong>Problem:</strong> Running <code>npm prune</code> before <code>npm install</code>
</div>
<div class="success" style="margin-top: 15px;">
<strong>Solution:</strong> Always install FIRST, then prune - correct order matters!
</div>
</div>
</div>
</div>
<div class="accordion-item">
<div class="accordion-header" onclick="toggleAccordion(this)">
<span><strong>3. Not Using npm ci in CI/CD</strong></span>
<span class="accordion-icon">โผ</span>
</div>
<div class="accordion-content">
<div class="accordion-body">
<div class="warning">
<strong>Problem:</strong> Using <code>npm install</code> in automated builds
</div>
<div class="success" style="margin-top: 15px;">
<strong>Solution:</strong> Use <code>npm ci</code> - it's faster, cleaner, and more reliable!
</div>
</div>
</div>
</div>
<div class="accordion-item">
<div class="accordion-header" onclick="toggleAccordion(this)">
<span><strong>4. Ignoring package-lock.json</strong></span>
<span class="accordion-icon">โผ</span>
</div>
<div class="accordion-content">
<div class="accordion-body">
<div class="warning">
<strong>Problem:</strong> Deleting or not committing package-lock.json
</div>
<div class="success" style="margin-top: 15px;">
<strong>Solution:</strong> Always commit package-lock.json - it ensures consistent installs!
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Pro Tips -->
<section class="section">
<h2 class="section-title">๐ Pro Tips</h2>
<div class="card">
<div class="tip">
<strong>Use npm ci</strong> - In CI/CD, use <code>npm ci</code> instead - it does both steps automatically!
</div>
<div class="tip">
<strong>Automate with postinstall</strong> - Add <code>"postinstall": "npm prune"</code> to package.json scripts!
</div>
<div class="tip">
<strong>Production installs</strong> - Use <code>--production</code> flag to exclude devDependencies!
</div>
<div class="tip">
<strong>Dry run first</strong> - Use <code>npm prune --dry-run</code> to see what would be removed!
</div>
<div class="tip">
<strong>After git pull</strong> - Always run install + prune after pulling changes!
</div>
<div class="tip">
<strong>Clean slate</strong> - Delete node_modules before install for a truly fresh start!
</div>
<div class="tip">
<strong>Commit lock file</strong> - Always commit package-lock.json for reproducible builds!
</div>
</div>
</section>
<!-- Quiz -->
<section class="section">
<h2 class="section-title">๐ฏ Knowledge Check Quiz</h2>
<div class="quiz-container">
<p style="margin-bottom: 30px; font-size: 1.1rem;">Test your understanding! ๐ง </p>
<div class="quiz-question">
<h3>Question 1: What's the correct order?</h3>
<div class="quiz-options">
<div class="quiz-option" onclick="checkAnswer(this, false, 1)">A) npm prune, then npm install</div>
<div class="quiz-option" onclick="checkAnswer(this, true, 1)">B) npm install, then npm prune</div>
<div class="quiz-option" onclick="checkAnswer(this, false, 1)">C) Order doesn't matter</div>
</div>
<div class="quiz-feedback" id="feedback1"></div>
</div>
<div class="quiz-question">
<h3>Question 2: What does npm prune do?</h3>
<div class="quiz-options">
<div class="quiz-option" onclick="checkAnswer(this, false, 2)">A) Updates all packages</div>
<div class="quiz-option" onclick="checkAnswer(this, true, 2)">B) Removes packages not in package.json</div>
<div class="quiz-option" onclick="checkAnswer(this, false, 2)">C) Installs missing packages</div>
</div>
<div class="quiz-feedback" id="feedback2"></div>
</div>
<div class="quiz-question">
<h3>Question 3: Best command for CI/CD?</h3>
<div class="quiz-options">
<div class="quiz-option" onclick="checkAnswer(this, false, 3)">A) npm install && npm prune</div>
<div class="quiz-option" onclick="checkAnswer(this, true, 3)">B) npm ci</div>
<div class="quiz-option" onclick="checkAnswer(this, false, 3)">C) npm install --production</div>
</div>
<div class="quiz-feedback" id="feedback3"></div>
</div>
<div id="quizScore" style="margin-top: 30px; padding: 20px; background: var(--bg-secondary); border-radius: 12px; display: none;">
<h3 style="color: var(--accent-green); font-size: 1.5rem;">๐ Quiz Complete!</h3>
<p id="scoreText" style="font-size: 1.2rem; margin-top: 10px;"></p>
</div>
</div>
</section>
<!-- Summary Card -->
<section class="section">
<h2 class="section-title">๐ Quick Reference</h2>
<div class="cheat-sheet">
<h3 style="margin-bottom: 20px; font-size: 2rem;">Install & Prune Cheat Sheet! ๐</h3>
<div class="cheat-grid">
<div class="cheat-item">
<h4>๐ฅ Install</h4>
<p><code>npm install</code></p>
<p style="font-size: 0.85rem; margin-top: 5px;">Get all dependencies</p>
</div>
<div class="cheat-item">
<h4>๐๏ธ Prune</h4>
<p><code>npm prune</code></p>
<p style="font-size: 0.85rem; margin-top: 5px;">Remove unused</p>
</div>
<div class="cheat-item">
<h4>๐ Combo</h4>
<p><code>npm install && npm prune</code></p>
<p style="font-size: 0.85rem; margin-top: 5px;">Both steps</p>
</div>
<div class="cheat-item">
<h4>โก CI/CD</h4>
<p><code>npm ci</code></p>
<p style="font-size: 0.85rem; margin-top: 5px;">Auto install+prune</p>
</div>
<div class="cheat-item">
<h4>๐ญ Production</h4>
<p><code>--production</code></p>
<p style="font-size: 0.85rem; margin-top: 5px;">No devDeps</p>
</div>
<div class="cheat-item">
<h4>๐ Dry Run</h4>
<p><code>npm prune --dry-run</code></p>
<p style="font-size: 0.85rem; margin-top: 5px;">Preview changes</p>
</div>
<div class="cheat-item">
<h4>๐ Order</h4>
<p>Install FIRST, then prune</p>
<p style="font-size: 0.85rem; margin-top: 5px;">Always!</p>
</div>
<div class="cheat-item">
<h4>โ
Result</h4>
<p>Clean node_modules</p>
<p style="font-size: 0.85rem; margin-top: 5px;">Optimized!</p>
</div>
</div>
</div>
</section>
<!-- Footer -->
<div class="footer">
<h2 style="font-size: 2rem; margin-bottom: 20px; color: var(--accent-pink);">๐ Congratulations!</h2>
<p style="font-size: 1.2rem; margin-bottom: 20px;">You now understand <strong>npm install & prune</strong>! ๐</p>
<div style="margin: 30px 0;">
<span class="badge">๐ฅ Install Master</span>
<span class="badge">๐งน Prune Expert</span>
<span class="badge">๐ npm Pro</span>
</div>
<p style="color: var(--text-secondary); margin-top: 30px;">Generated by <strong>AI Prompt Dictionary</strong> ๐ค</p>
<p style="color: var(--text-secondary); font-size: 0.9rem;">Made with โค๏ธ for developers learning npm</p>
</div>
</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 + '%';
});
// Copy to clipboard
function copyCode(codeId) {
const code = document.getElementById(codeId).innerText;
navigator.clipboard.writeText(code).then(() => {
event.target.textContent = 'โ
Copied!';
event.target.classList.add('copied');
setTimeout(() => {
event.target.textContent = '๐ Copy';
event.target.classList.remove('copied');
}, 2000);
});
}
// Tab switching
function switchTab(tabName) {
document.querySelectorAll('.tab-content').forEach(c => c.classList.remove('active'));
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
document.getElementById(tabName).classList.add('active');
event.target.classList.add('active');
}
// Accordion toggle
function toggleAccordion(header) {
const content = header.nextElementSibling;
const icon = header.querySelector('.accordion-icon');
content.classList.toggle('active');
icon.classList.toggle('active');
}
// Simulate install
function simulateInstall() {
const terminal = document.getElementById('terminal');
terminal.innerHTML = '<div class="terminal-line"><span class="terminal-prompt">$</span> npm install</div>';
setTimeout(() => {
terminal.innerHTML += '<div style="color: var(--accent-cyan); margin-top: 10px;">๐ Reading package.json...</div>';
}, 500);
setTimeout(() => {
terminal.innerHTML += '<div style="color: var(--accent-blue); margin-top: 10px;">๐ฅ Downloading packages...</div>';
terminal.innerHTML += '<div style="color: var(--text-secondary); margin-left: 20px;">+ express@4.18.2</div>';
terminal.innerHTML += '<div style="color: var(--text-secondary); margin-left: 20px;">+ lodash@4.17.21</div>';
terminal.innerHTML += '<div style="color: var(--text-secondary); margin-left: 20px;">+ axios@1.4.0</div>';
}, 1500);
setTimeout(() => {
terminal.innerHTML += '<div style="color: var(--accent-green); margin-top: 10px; font-weight: 600;">โ
Installed 3 packages in 2.5s</div>';
terminal.innerHTML += '<div style="color: var(--accent-cyan); margin-top: 5px;">๐ฆ node_modules created successfully!</div>';
createConfetti();
}, 2800);
}
// Simulate prune
function simulatePrune() {
const terminal = document.getElementById('terminal');
terminal.innerHTML = '<div class="terminal-line"><span class="terminal-prompt">$</span> npm prune</div>';
setTimeout(() => {
terminal.innerHTML += '<div style="color: var(--accent-cyan); margin-top: 10px;">๐ Scanning node_modules...</div>';
}, 500);
setTimeout(() => {
terminal.innerHTML += '<div style="color: var(--accent-yellow); margin-top: 10px;">๐ Comparing with package.json...</div>';
terminal.innerHTML += '<div style="color: var(--text-secondary); margin-left: 20px;">Found 2 unused packages</div>';
}, 1500);
setTimeout(() => {
terminal.innerHTML += '<div style="color: var(--accent-red); margin-top: 10px;">๐๏ธ Removing unused packages...</div>';
terminal.innerHTML += '<div style="color: var(--text-secondary); margin-left: 20px;">- old-package@1.0.0</div>';
terminal.innerHTML += '<div style="color: var(--text-secondary); margin-left: 20px;">- unused-lib@2.3.1</div>';
}, 2500);
setTimeout(() => {
terminal.innerHTML += '<div style="color: var(--accent-green); margin-top: 10px; font-weight: 600;">โ
Removed 2 packages</div>';
terminal.innerHTML += '<div style="color: var(--accent-cyan); margin-top: 5px;">๐งน node_modules cleaned!</div>';
createConfetti();
}, 3500);
}
// Simulate full combo
function simulateCombo() {
const terminal = document.getElementById('terminal');
terminal.innerHTML = '<div class="terminal-line"><span class="terminal-prompt">$</span> npm install && npm prune</div>';
setTimeout(() => {
terminal.innerHTML += '<div style="color: var(--accent-green); margin-top: 15px; font-weight: 600;">๐ฅ STEP 1: npm install</div>';
terminal.innerHTML += '<div style="color: var(--accent-cyan); margin-left: 20px;">๐ Reading package.json...</div>';
}, 500);
setTimeout(() => {
terminal.innerHTML += '<div style="color: var(--accent-blue); margin-left: 20px;">๐ฅ Installing dependencies...</div>';
terminal.innerHTML += '<div style="color: var(--text-secondary); margin-left: 40px;">+ express@4.18.2</div>';
terminal.innerHTML += '<div style="color: var(--text-secondary); margin-left: 40px;">+ lodash@4.17.21</div>';
}, 1500);
setTimeout(() => {
terminal.innerHTML += '<div style="color: var(--accent-green); margin-left: 20px;">โ
Install complete!</div>';
}, 2500);
setTimeout(() => {
terminal.innerHTML += '<div style="color: var(--accent-red); margin-top: 15px; font-weight: 600;">๐๏ธ STEP 2: npm prune</div>';
terminal.innerHTML += '<div style="color: var(--accent-cyan); margin-left: 20px;">๐ Scanning for unused packages...</div>';
}, 3000);
setTimeout(() => {
terminal.innerHTML += '<div style="color: var(--accent-yellow); margin-left: 20px;">๐๏ธ Removing 1 unused package...</div>';
terminal.innerHTML += '<div style="color: var(--text-secondary); margin-left: 40px;">- old-package@1.0.0</div>';
}, 4000);
setTimeout(() => {
terminal.innerHTML += '<div style="color: var(--accent-green); margin-left: 20px;">โ
Prune complete!</div>';
terminal.innerHTML += '<div style="color: var(--accent-purple); margin-top: 20px; font-weight: 600; font-size: 1.1rem;">๐ SUCCESS! node_modules is perfectly clean!</div>';
terminal.innerHTML += '<div style="color: var(--accent-cyan); margin-top: 5px;">โจ All dependencies installed, unused packages removed</div>';
createConfetti();
}, 5000);
}
// Quiz system
let quizScore = 0;
let questionsAnswered = 0;
function checkAnswer(element, isCorrect, questionNum) {
const options = element.parentElement.querySelectorAll('.quiz-option');
options.forEach(opt => opt.style.pointerEvents = 'none');
const feedback = document.getElementById('feedback' + questionNum);
if (isCorrect) {
element.classList.add('correct');
feedback.className = 'quiz-feedback correct show';
feedback.innerHTML = '<strong>๐ Correct!</strong> Great job!';
quizScore++;
createConfetti();
} else {
element.classList.add('incorrect');
feedback.className = 'quiz-feedback incorrect show';
feedback.innerHTML = '<strong>โ Not quite!</strong> Review the material and try again!';
}
questionsAnswered++;
if (questionsAnswered === 3) {
setTimeout(() => {
document.getElementById('quizScore').style.display = 'block';
document.getElementById('scoreText').textContent = `You scored ${quizScore}/3! ${quizScore === 3 ? '๐ Perfect!' : quizScore === 2 ? '๐ Good job!' : '๐ช Keep learning!'}`;
}, 1000);
}
}
// Confetti animation
function createConfetti() {
const colors = ['#10b981', '#3b82f6', '#ef4444', '#a855f7', '#f59e0b'];
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 = colors[Math.floor(Math.random() * colors.length)];
confetti.style.animationDuration = (2 + Math.random() * 2) + 's';
document.body.appendChild(confetti);
setTimeout(() => confetti.remove(), 4000);
}
}
</script>
</body>
</html>
Live Preview