live-server not reloading browser #4

Closed
opened 2024-01-11 21:10:04 +00:00 by SamuelCano03 · 11 comments
SamuelCano03 commented 2024-01-11 21:10:04 +00:00

Info

I downloaded live-server for nvim with lazy. also globally with npm. It works when running LiveServerStart, but saved changes are not reloaded in the browser. I have to manually reload the browser to see the changes.

  • Operating System: Ubuntu22.04
  • nvim --version: v0.9.4
  • Node package manager:
  • <node-package-manager> --version: nvm 0.38.0
  • live-server --version: 1.2.2

Configuration

this is my config located in custom.plugins.lua (I'm using nvchad distro of nvim):

{
        "barrett-ruth/live-server.nvim",
        build = "npm install -g live-server",
        event={"BufReadPre", "BufNewFile"}, --this is for initiate live-server in new buffer
        config=true,
     },
this is what console in browser shows: `Live reload enabled.`

Description

Another thing i noticed, is when running LiveServerStop, i got this message: live-server.nvim: stopped with code 143
Even If I don't make any change to the html file, i got that message when running LiveServerStop.

This is my html file if it is important

<!DOCTYPE html>
<html lang="en">
     <head>
          <title></title>
          <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1">
          <!-- <link href="css/style.css" rel="stylesheet"> -->
     </head>
     <body>
          <h1>Hi</h1> 
     </body>
</html>

It was working very well before, I don't know what happened :'/

### Info I downloaded live-server for nvim with lazy. also globally with npm. It works when running `LiveServerStart`, but saved changes are not reloaded in the browser. I have to manually reload the browser to see the changes. - Operating System: Ubuntu22.04 - `nvim --version`: v0.9.4 - Node package manager: - `<node-package-manager> --version`: nvm 0.38.0 - `live-server --version`: 1.2.2 ### Configuration <!-- Replace the below with your live-server.nvim setup --> this is my config located in custom.plugins.lua (I'm using nvchad distro of nvim): ``` { "barrett-ruth/live-server.nvim", build = "npm install -g live-server", event={"BufReadPre", "BufNewFile"}, --this is for initiate live-server in new buffer config=true, }, ``` </details> this is what console in browser shows: `Live reload enabled.` ### Description Another thing i noticed, is when running LiveServerStop, i got this message: `live-server.nvim: stopped with code 143` Even If I don't make any change to the html file, i got that message when running LiveServerStop. This is my html file if it is important ``` <!DOCTYPE html> <html lang="en"> <head> <title></title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- <link href="css/style.css" rel="stylesheet"> --> </head> <body> <h1>Hi</h1> </body> </html> ``` It was working very well before, I don't know what happened :'/
barrettruth commented 2024-01-14 18:04:08 +00:00

Two things:

  1. can you give me more information on your operating system, browser, etc.
  2. can you try this configuration again but remove the event field from the lazy configuration.
  3. run live-server . yourself and open up the browser on the file you're working on. if that doesn't work, then it is a problem with liver-server and not live-server.nvim. If the file you're working on is indeed the one being rendered in the browser, a failure to update is probably not coming from live-server.
Two things: 1. can you give me more information on your operating system, browser, etc. 2. can you try this configuration again but remove the `event` field from the lazy configuration. 3. run `live-server .` yourself and open up the browser on the file you're working on. if that doesn't work, then it is a problem with liver-server and not live-server.nvim. If the file you're working on is indeed the one being rendered in the browser, a failure to update is probably not coming from live-server.
SamuelCano03 commented 2024-01-14 20:53:30 +00:00

Yes sir and thank you for your response and your time. Here you have the specs:

  1. can you give me more information on your operating system, browser, etc.
  • Operating System (uname -a) : Linux Lenova 6.5.0-14-generic #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
  • Browser: Brave 1.61.116 Chromium: 120.0.6099.217 (Official Build) (64-bit)
  1. can you try this configuration again but remove the event field from the lazy configuration.
  • I have removed the event field, but the issue persists.
  1. run live-server . yourself and open up the browser on the file you're working on. if that doesn't work, then it is a problem with liver-server and not live-server.nvim. If the file you're working on is indeed the one being rendered in the browser, a failure to update is probably not coming from live-server.
  • I runned live-server . and everything was working OK even with and without the event field in lazy config. (I've been previously trying with live-server without the '.' and it didn't reload the browser for new changes, the same issue with :LiveServerStart). Even tho, the command :LiveServerStart for nvim is not working. I will be using live-server . in the terminal but I'll be waiting for a response for the issue too so if you need more details I'll be aware :)
Yes sir and thank you for your response and your time. Here you have the specs: > 1. can you give me more information on your operating system, browser, etc. - Operating System (`uname -a`) : `Linux Lenova 6.5.0-14-generic #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2 x86_64 x86_64 x86_64 GNU/Linux` - Browser: *Brave* 1.61.116 Chromium: 120.0.6099.217 (Official Build) (64-bit) > 2. can you try this configuration again but remove the `event` field from the lazy configuration. - I have removed the `event` field, but the issue persists. > 3. run `live-server .` yourself and open up the browser on the file you're working on. if that doesn't work, then it is a problem with liver-server and not live-server.nvim. If the file you're working on is indeed the one being rendered in the browser, a failure to update is probably not coming from live-server. - I runned `live-server .` and everything was working OK even with and without the `event` field in lazy config. (I've been previously trying with `live-server` without the '.' and it didn't reload the browser for new changes, the same issue with `:LiveServerStart`). Even tho, the command `:LiveServerStart` for nvim is not working. I will be using `live-server .` in the terminal but I'll be waiting for a response for the issue too so if you need more details I'll be aware :)
barrettruth commented 2024-01-24 15:15:12 +00:00

I just updated the docs on configuring live-server.nvim with lazy, so delete the plugin and reinstall with that configuration.

Also,

  1. Paste the output of vim.fn.executable('live-server') - this should be 1. If NeoVim can't find live-server then there's something wrongh with your setup.

BTW, I just pushed a change that fixes the "live-server stopped with code 143."

I just updated the docs on configuring `live-server.nvim` with lazy, so delete the plugin and reinstall with that configuration. Also, 1. Paste the output of `vim.fn.executable('live-server')` - this should be 1. If NeoVim can't find live-server then there's something wrongh with your setup. BTW, I just pushed a change that fixes the "live-server stopped with code 143."
SamuelCano03 commented 2024-01-26 16:35:17 +00:00

I've reinstalled the plugin with the new configurations. I don't use pnpm but I've tried to build the plugin with it without success, so I did it with npm. The live-server stopped message is updated. The issue persists tho.

 {
        "barrett-ruth/live-server.nvim",
        build = "npm install -g live-server",
        cmd = { 'LiveServerStart', 'LiveServerStop' },
        -- event={"BufReadPre", "BufNewFile"},
        config=true,
},

the output when I do :echo executable('live-server') is 1.

This is the log of Lazy:

image

I've reinstalled the plugin with the new configurations. I don't use pnpm but I've tried to build the plugin with it without success, so I did it with npm. The live-server stopped message is updated. The issue persists tho. ``` { "barrett-ruth/live-server.nvim", build = "npm install -g live-server", cmd = { 'LiveServerStart', 'LiveServerStop' }, -- event={"BufReadPre", "BufNewFile"}, config=true, }, ``` the output when I do `:echo executable('live-server')` is 1. This is the log of Lazy: ![image](https://github.com/barrett-ruth/live-server.nvim/assets/102400537/3c090fed-775d-4e95-90d2-48e0bd1853b8)
barrettruth commented 2024-01-28 00:18:18 +00:00

Sorry about this bug, it is really confounding. Take for example below, where I start the live-server via :LiveServerStart then view the process and see it is running with ps aux | grep live-server. So, you are saying if you start live-server via the CLI, the browser reflects changes, but via live-server.nvim, it doesn't?

If that's the case, then try to replicate the setup below:
image

Lastly, the plugin is only about 100 lines long, so debug on your own if you're willing (I should probably add a debug mode myself).

Sorry about this bug, it is really confounding. Take for example below, where I start the live-server via `:LiveServerStart` then view the process and see it is running with `ps aux | grep live-server`. So, you are saying if you start live-server via the CLI, the browser reflects changes, but via live-server.nvim, it doesn't? If that's the case, then try to replicate the setup below: <img width="1511" alt="image" src="https://github.com/barrett-ruth/live-server.nvim/assets/62671086/9edfd956-072e-42b2-b2d9-a23c46e3197f"> Lastly, the plugin is only about 100 lines long, so debug on your own if you're willing (I should probably add a debug mode myself).
SamuelCano03 commented 2024-01-28 20:11:25 +00:00

I've recorded my screen so you can see more clearly how the bug is. As you can see, using :LiveStartServer and live-server have the same bug (I need to reload the browser to see changes). But running live-server . works fine.

https://github.com/barrett-ruth/live-server.nvim/assets/102400537/b1faf6d3-8999-419b-b4a9-062188e8a902

This is the output of ps aux | grep live-server when running :LiveStartServer

image

This is the output when running live-server .

image

Hope the bug is clearer now.

I've recorded my screen so you can see more clearly how the bug is. As you can see, using `:LiveStartServer` and `live-server` have the same bug (I need to reload the browser to see changes). But running `live-server .` works fine. https://github.com/barrett-ruth/live-server.nvim/assets/102400537/b1faf6d3-8999-419b-b4a9-062188e8a902 This is the output of `ps aux | grep live-server` when running `:LiveStartServer` ![image](https://github.com/barrett-ruth/live-server.nvim/assets/102400537/fe348b97-57ba-4e9d-8e46-81fb097ec2ab) This is the output when running `live-server .` ![image](https://github.com/barrett-ruth/live-server.nvim/assets/102400537/a06f7783-0e02-4239-b363-1d1083cd95e3) Hope the bug is clearer now.
barrettruth commented 2024-01-29 00:19:06 +00:00

@SamuelCano03 thanks for the video that is actually helpful.

Can you also run live-server /home/samuelDesktop/.proy from the command line and see if the browser will reload?

gracias :D

@SamuelCano03 thanks for the video that is actually helpful. Can you also run `live-server /home/samuelDesktop/.proy` from the command line and see if the browser will reload? gracias :D
SamuelCano03 commented 2024-01-29 15:02:10 +00:00

The same issue, browser doesn't reload.

If it is important, here is the output of ps aux | grep live-server

image

This is what I see when pressing f12 in browser:

image

This is the output of the console of the browser:

image

The same issue, browser doesn't reload. If it is important, here is the output of ps aux | grep live-server ![image](https://github.com/barrett-ruth/live-server.nvim/assets/102400537/db1aa4c6-1533-4df1-b8c6-dea8a016e503) This is what I see when pressing f12 in browser: ![image](https://github.com/barrett-ruth/live-server.nvim/assets/102400537/cb2e2207-7b84-4362-b162-19a72294b828) This is the output of the console of the browser: ![image](https://github.com/barrett-ruth/live-server.nvim/assets/102400537/9b9e4208-5164-4ab4-a4ac-341f26171f6b)
SamuelCano03 commented 2024-01-29 15:39:55 +00:00

@barrett-ruth notice that when running live-server in CLI, after saving changes , there is no Change detected index.html in console (min 0:39). But when running live-server ., it does show the change detected message after saving changes (min 1:01)

@barrett-ruth notice that when running `live-server` in CLI, after saving changes , there is no `Change detected index.html` in console (min 0:39). But when running `live-server .`, it does show the change detected message after saving changes (min 1:01)
barrettruth commented 2024-01-29 17:19:09 +00:00

it's because the directory is hidden. I replicated the issue using a hidden .proy directory, and the issue went away using a non-hidden directory. I suggest you do not work on major projects using hidden directories - that doesn't seem to make much sense. Otherwise, report the issue with the live-server package directly.

I definitely should've caught this issue earlier - sorry for how long this took to debug. Let me know if you have any other comments, but I don't think there's anything on live-server.nvim's end to change.

it's because the directory is hidden. I replicated the issue using a hidden `.proy` directory, and the issue went away using a non-hidden directory. I suggest you do not work on major projects using hidden directories - that doesn't seem to make much sense. Otherwise, report the issue with the live-server package directly. I definitely should've caught this issue earlier - sorry for how long this took to debug. Let me know if you have any other comments, but I don't think there's anything on live-server.nvim's end to change.
SamuelCano03 commented 2024-01-29 17:27:27 +00:00

Thank you very much sorry for the large debug too

Thank you very much sorry for the large debug too
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
barrettruth/live-server.nvim#4
No description provided.