Problem: AI Keeps Suggesting moment.js and Other Dead Libraries
Your AI assistant suggests moment.js for dates, request for HTTP calls, or node-sass for styling—all deprecated years ago. You waste time debugging obsolete code.
You'll learn:
- Why AI models recommend outdated packages
- How to add context that prevents this
- Which libraries to watch for in 2026
Time: 5 min | Level: Beginner
Why This Happens
AI models trained on historical code see deprecated libraries used frequently in older projects. Without explicit instructions, they default to patterns from their training data (often 2021-2023 code).
Common symptoms:
- Suggestions for
moment.jsinstead of nativeTemporalordate-fns create-react-appinstead of Vitenode-sassinstead ofsass(Dart Sass)- Packages with npm deprecation warnings
Solution
Step 1: Add Context to Your Prompts
For any AI assistant (Copilot, Claude, ChatGPT):
Before suggesting libraries:
- Check if packages are actively maintained (npm last publish < 6 months)
- Avoid deprecated packages (moment.js, request, node-sass, CRA)
- Prefer native APIs when available (Fetch over axios, Temporal over date libraries)
- Use Vite/Next.js instead of create-react-app
Where to put this:
- GitHub Copilot: Add to
.github/copilot-instructions.mdin your repo root - Claude: Include in your project's
README.mdor initial message - ChatGPT/Cursor: Paste at the start of coding sessions
Step 2: Create a Project Blocklist
# .ai-preferences.yml (or in README)
deprecated_packages:
- moment # Use: date-fns, Temporal API, dayjs
- request # Use: native fetch, axios, got
- node-sass # Use: sass (Dart Sass)
- gulp # Use: npm scripts, Vite
- bower # Use: npm, pnpm
- create-react-app # Use: Vite, Next.js
prefer_modern:
dates: "Temporal API (native) or date-fns"
http: "fetch (native) or undici"
build: "Vite or esbuild"
css: "Tailwind CSS or vanilla CSS modules"
Reference this file when asking for code: "Check .ai-preferences.yml before suggesting packages."
Step 3: Verify Suggestions with npm
# Check if a package is maintained
npm view <package-name> time.modified
# Example
npm view moment time.modified
# Returns: 2022-07-07 (not maintained)
npm view date-fns time.modified
# Returns: 2024-12-15 (actively maintained)
If last update is >12 months old: Ask AI for alternatives.
Step 4: Set AI Tool Configurations
GitHub Copilot (VS Code):
Create .github/copilot-instructions.md:
# Copilot Instructions
## Package Selection Rules
1. Never suggest: moment, request, node-sass, create-react-app
2. For dates: Use Temporal API (Node 22+) or date-fns
3. For HTTP: Use native fetch or undici
4. For React: Use Vite or Next.js starter
5. Check npm "last publish" before suggesting (must be <6 months)
## Project Context
- Node.js: 22+
- TypeScript: 5.5+
- React: 19+
Cursor/Windsurf:
Add to cursor_rules or project instructions:
@Modern Stack Rules
- Use ESM imports only
- Prefer native APIs (fetch, Temporal)
- No deprecated packages (see .ai-preferences.yml)
- Suggest pnpm over npm
Verification
Test it:
Ask your AI: "Add date formatting to this React component"
You should see:
- ✅
date-fnsor nativeIntl.DateTimeFormat - ✅
Temporal.Now(if Node 22+) - ❌ NOT
moment.js
If it still suggests moment:
- Add "Don't use moment.js" to your prompt
- Reference your
.ai-preferences.ymlfile - Specify the year: "Using 2026 best practices..."
Common Deprecated Packages in 2026
| Don't Use | Use Instead | Why |
|---|---|---|
moment.js | date-fns, Temporal API | 50KB bundle, unmaintained |
request | fetch (native), undici | Deprecated 2020 |
node-sass | sass (Dart Sass) | C++ dependency issues |
create-react-app | Vite, Next.js | No updates since 2023 |
axios (debatable) | fetch (native) | Native is sufficient for most cases |
lodash (full) | Import specific functions | Tree-shaking issues |
webpack (alone) | Vite, esbuild | Slower, complex config |
What You Learned
- AI models default to patterns from older training data
- Explicit context in prompts prevents outdated suggestions
- Project-level instruction files guide AI tools consistently
- Always verify package maintenance status before using
Limitations:
- AI might still suggest deprecated packages if they're in your existing codebase
- Some tools don't support instruction files (use prompts instead)
Quick Reference: AI Context Template
Copy this into your prompts:
Context for AI Assistant:
- Year: 2026
- Node.js: 22+ (native fetch, Temporal API available)
- Avoid: moment, request, node-sass, create-react-app
- Prefer: Native APIs > Modern maintained packages > Deprecated tools
- Check npm last publish date before suggesting
Tested with GitHub Copilot, Claude Code, ChatGPT o1, Cursor 0.43 - February 2026