slidev icon indicating copy to clipboard operation
slidev copied to clipboard

Problem : cannot open localhost:3030 inside WSL2

Open ych817 opened this issue 9 months ago • 4 comments

I am using windows 11 with WSL2 . I installed all code developing environment inside WSL2 .

  • version of WSL2 : 2.4.11.0
  • version of Ubuntu : 24.04.2 LTS
  • version of Node : 22.14.0
  • version of pnpm : 10.6.4
  • version of nvm : 0.40.1

I entered pnpm create slidev today ( 21 March 2025 , slidev v51.4.0 ) inside WSL and everything goes fine , except that http://localhost:3030 cannot show the slides .

The same thing also happened when I tweaking HUGO theme . The way I solve it is written in this article . Not sure if this can be used in our case .

Any suggestions ?

ych817 avatar Mar 21 '25 05:03 ych817

Fixed . Here is a quite ugly solution :

  • First use ifconfig to checkout the inet :

    eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 172.17.72.111  netmask 255.255.240.0  broadcast 172.17.79.255
            inet6 fe80::215:5dff:fef2:a904  prefixlen 64  scopeid 0x20<link>
            ether 00:15:5d:f2:a9:04  txqueuelen 1000  (Ethernet)
            RX packets 6725  bytes 25268609 (25.2 MB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 7299  bytes 137710315 (137.7 MB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            inet6 ::1  prefixlen 128  scopeid 0x10<host>
            loop  txqueuelen 1000  (Local Loopback)
            RX packets 6587  bytes 49251803 (49.2 MB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 6587  bytes 49251803 (49.2 MB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
  • Notice that inet 172.17.72.111 , therefore use pnpm run dev --remote --bind 172.17.72.111 and you can run Slidev .

ych817 avatar Mar 21 '25 23:03 ych817

However I cannot preview the slide inside vscode . Is there any way to modify the default address for slidev extension preview ?

Image

ych817 avatar Mar 22 '25 00:03 ych817

I got the same issue with devcontaininer. Using the extension is a workaround

valeriocomo avatar Oct 06 '25 04:10 valeriocomo

是不是wsl的问题呀。用networkingMode可以嘛

Image

abearxiong avatar Oct 25 '25 16:10 abearxiong