SKILL.md--- name: npm-helper description: NPM and Node.js package management, project configuration, and dependency troubleshooting. --- # NPM Package Management Assistant Skill NPM and Node.js package management, project configuration, and dependency troubleshooting. ## Instructions You are a Node.js and NPM ecosystem expert. When invoked: 1. **Package Management**: - Install and manage npm packages - Handle package.json configuration - Manage lock files (package-lock.json) - Use npm, yarn, or pnpm effectively - Configure workspaces and monorepos 2. **Project Setup**: - Initialize new Node.js projects - Configure scripts and lifecycle hooks - Set up project structure - Configure development tools - Manage multiple package managers 3. **Dependency Management**: - Handle version ranges and semver - Resolve dependency conflicts - Audit for security vulnerabilities - Update dependencies safely - Manage peer dependencies 4. **Troubleshooting**: - Fix module resolution errors - Resolve version conflicts - Debug installation issues - Clear cache and rebuild - Handle platform-specific issues 5. **Best Practices**: Provide guidance on package management, versioning, security, and performance optimization ## Package Manager Comparison ### npm (Default) ```bash # Pros: Default in Node.js, widely supported # Cons: Slower than alternatives # Initialize project npm init npm init -y # Skip prompts # Install dependencies npm install express npm install --save-dev jest # Install all dependencies npm install # Update dependencies npm update npm update express # Remove package npm uninstall express # Run scripts npm run build npm test # Shorthand for npm run test npm start # Shorthand for npm run start # List installed packages npm list npm list --depth=0 # Only top-level # Check for outdated packages npm outdated ``` ### Yarn (v1 Classic) ```bash # Pros: Faster, better UX, workspaces # Cons: Extra tool to install # Install Yarn npm install -g yarn # Initialize project yarn init yarn init -y # Install dependencies yarn add express yarn add --dev jest # Install all dependencies yarn install yarn # Shorthand # Update dependencies yarn upgrade yarn upgrade express # Remove package yarn remove express # Run scripts yarn build yarn test yarn start # List installed packages yarn list yarn list --depth=0 # Check for outdated packages yarn outdated # Interactive upgrade yarn upgrade-interactive ``` ### pnpm (Fast & Efficient) ```bash # Pros: Fastest, disk space efficient, strict # Cons: Less common, some compatibility issues # Install pnpm npm install -g pnpm # Initialize project pnpm init # Install dependencies pnpm add express pnpm add -D jest # Install all dependencies pnpm install # Update dependencies pnpm update pnpm update express # Remove package pnpm remove express # Run scripts pnpm build pnpm test pnpm start # List installed packages pnpm list pnpm list --depth=0 # Check