Skip to content

Instantly share code, notes, and snippets.

@Vesely
Last active January 19, 2026 13:00
Show Gist options
  • Select an option

  • Save Vesely/5bf2910820031dc3ee2b897b49b8ff61 to your computer and use it in GitHub Desktop.

Select an option

Save Vesely/5bf2910820031dc3ee2b897b49b8ff61 to your computer and use it in GitHub Desktop.

Run Project on Localhost

Detect project type and run on localhost.

Steps

  1. Detect project type

    • package.json → Node.js, requirements.txt/pyproject.toml → Python
  2. Detect package manager (Node.js)

    • Check lock files: bun.lock/bun.lockb → bun, pnpm-lock.yaml → pnpm, yarn.lock → yarn, package-lock.json → npm
    • Else check package.json packageManager field, default npm
  3. Install dependencies if needed

    • Node.js: If no node_modules, run <packageManager> install
    • Python: If missing packages, run pip install -r requirements.txt or pip install -e .
  4. Run and detect URL

    • Node.js: Check package.json scripts for dev/start/serve, run <packageManager> run <script> in background with required_permissions: ["all"]
    • Python: Run uvicorn, gunicorn, flask run, or python app.py in background
    • Poll output until URL appears (0.5s intervals, 10s max)
    • Parse for: "http://localhost:PORT", "http://127.0.0.1:PORT", "Listening on port PORT"
    • If detected port differs from default (3000/8000), kill process on default port: lsof -ti:PORT | xargs kill -9
    • Display URL as hyperlink, open in browser with browser_navigate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment