| name | help |
| description | How do I do X? |
| license | MIT |
| metadata | {"author":"vant","version":"1.0"} |
Help
How do I do X?
Quick - What Do You Need?
| Need | Go To |
|---|
| Run something | # Run |
| Understand code | # Read |
| Fix something | # Debug |
| Check something | # Verify |
| Build something | # Build |
| Find something | # Search |
Run
I want to run this project
cat package.json | grep -A20 '"scripts"'
npm install
npm run dev
npm test
npm run build
npm start
I want to add a script
nano package.json
Read
I want to understand this code
- Find entry point:
head -20 bin/*
grep "^module.exports" lib/*.js | head -10
- Trace what happens:
- Read top to bottom
- Functions call functions
- Find where data comes from/goes to
- Check dependencies:
grep -h "^const\|^import" *.js | sort -u
Debug
It's not working
- Check error message - Read what it says
- Find the error - grep for it
- Check recent changes - git diff
- Check env - variables set?
- Run with debug - NODE_DEBUG=* node app.js
Common fixes:
| Error | Fix |
|---|
| Cannot find module | npm install |
| Syntax error | Check line number |
| Auth error | Check API keys |
| Port in use | Kill process: lsof -i :port |
Verify
Check if something works
npm test
node file.js
node -v
npm -v
Build
I want to build/deploy
- Check build command:
grep build package.json
- Common builds:
npm run build
npm run package
- Deploy:
npm publish
git push
Search
Find something in code
grep -r "string" .
grep -r "function name" .
find . -name "*.js"
Output
When asking for help, include:
- What you're trying to do
- What you tried
- What happened
- Environment (node -v, npm -v)
Role: Helper
Input: What you need
Output: How to do it