Image

Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Gelert's avatar

Gelert wrote a comment+100 XP

6mos ago

The Docker Tutorial: Ep 7, Running Artisan and NPM

@MattiaFontana I found a solution to this:

  npm:
    image: node:current-alpine
    ports:
      - "5175:5175"
    environment:
      - VITE_DEV_SERVER_URL=http://localhost:5175
    volumes:
      - ./src:/var/www/html
    user: "node"
    working_dir: /var/www/html
    networks:
      - laravel
    entrypoint: sh
    command:
      - -c
      - "npm run dev -- --host --port 5175 & PID=$$! && sleep 3 && echo 'http://localhost:5175' > /var/www/html/public/hot && wait $$PID"

It's a bit of a hack because it's re-writing the hot file! At least Vite works now.

I'm using 5175 because I have Laravel Herd running other ports for npm.

Gelert's avatar

Gelert liked a comment+100 XP

6mos ago

The Docker Tutorial: Ep 7, Running Artisan and NPM

We're a couple of years later and now in Vite era.

Despite adding port 5173 under php and adding a hmr server in vite.config, for the life of me, I cannot access localhost:5173 after npm run dev

Any hints?