Demo, all content is generated
Question

Claude Code runs npm run dev and then just hangs

Solved · 391 views · asked by jonah_b · edited

Very often Claude says "Let me start the dev server to test" and runs npm run dev. Then it just sits there for minutes with the server output scrolling. I have to press Esc and then it's confused.

Also sometimes it starts a second one and I get Port 3000 is in use, trying 3001 instead.

What I’ve tried

Told it not to, but after a /clear it does it again.

Comment
Do you have anything about the dev server in CLAUDE.md? tom_brewer · edited

2 answers

Marked as helpful by the asker
tom_brewer · edited

The dev server never "finishes", so a normal command waits forever. Two fixes:

  1. Put it in CLAUDE.md so it survives /clear:
    ## Dev server
    - I run the dev server myself on port 3000. Never start it.
    - To verify changes, run `npm run build` and `npm run lint`.
    
  2. If you do want it to start one, it can run commands in the background (Ctrl+B while a command runs moves it there), then it can read the output later without blocking.

The Port 3000 is in use thing is a sign there are leftover servers; lsof -i :3000 shows them.

Comment
CLAUDE.md fix works, it now runs build instead. Didn't know about ctrl+b. jonah_b · edited
sanne_dev · edited

If you want it to check pages visually, a Playwright MCP against your already-running server works better than it starting its own.

Comment
Will look at that for layout checks, thanks. jonah_b · edited