[Bug] can't handle relative path properly #3

Closed
opened 2023-12-21 07:59:38 +00:00 by shellRaining · 8 comments
shellRaining commented 2023-12-21 07:59:38 +00:00

Info

  • Operating System: Mac OS
  • nvim --version: 0.9.4
  • Node package manager: v21.5.0
  • <node-package-manager> --version: 10.2.4
  • live-server --version: live-server 1.2.2

Configuration

use lazy and just use config = true

    { "barrett-ruth/live-server.nvim", build = "npm install -g live-server", config = true },

Description

import { App } from "./App.js";
import { createApp } from "../../lib/miniVue.esm.js";

I am sure that miniVue.esm.js is exist and can use gf to jump to this file, however, browser report that

GET http://127.0.0.1:8080/lib/miniVue.esm.js net::ERR_ABORTED 404 (Not Found)

the same plugin in vscode is work properly, so I guess it is a bug of this plugin

### Info - Operating System: Mac OS - `nvim --version`: 0.9.4 - Node package manager: v21.5.0 - `<node-package-manager> --version`: 10.2.4 - `live-server --version`: live-server 1.2.2 ### Configuration use `lazy` and just use `config = true` ```lua { "barrett-ruth/live-server.nvim", build = "npm install -g live-server", config = true }, ``` ### Description ```js import { App } from "./App.js"; import { createApp } from "../../lib/miniVue.esm.js"; ``` I am sure that `miniVue.esm.js` is exist and can use `gf` to jump to this file, however, browser report that ``` GET http://127.0.0.1:8080/lib/miniVue.esm.js net::ERR_ABORTED 404 (Not Found) ``` the same plugin in vscode is work properly, so I guess it is a bug of this plugin
barrettruth commented 2023-12-21 17:52:53 +00:00

Hey, sorry about the issue - can you provide a boilerplate so I can duplicate the error?

Thanks.

Hey, sorry about the issue - can you provide a boilerplate so I can duplicate the error? Thanks.

Exact same setup works for me.

Exact same setup works for me.

Info

  • Operating System: Mac OS
  • nvim --version: 0.9.4
  • Node package manager: v21.5.0
  • <node-package-manager> --version: 10.2.4
  • live-server --version: live-server 1.2.2

Configuration

use lazy and just use config = true

    { "barrett-ruth/live-server.nvim", build = "npm install -g live-server", config = true },

Description

import { App } from "./App.js";
import { createApp } from "../../lib/miniVue.esm.js";

I am sure that miniVue.esm.js is exist and can use gf to jump to this file, however, browser report that

GET http://127.0.0.1:8080/lib/miniVue.esm.js net::ERR_ABORTED 404 (Not Found)

the same plugin in vscode is work properly, so I guess it is a bug of this plugin

https://www.npmjs.com/package/live-server checkout the follwoing

> ### Info > * Operating System: Mac OS > * `nvim --version`: 0.9.4 > * Node package manager: v21.5.0 > * `<node-package-manager> --version`: 10.2.4 > * `live-server --version`: live-server 1.2.2 > > ### Configuration > use `lazy` and just use `config = true` > > ```lua > { "barrett-ruth/live-server.nvim", build = "npm install -g live-server", config = true }, > ``` > > ### Description > ```js > import { App } from "./App.js"; > import { createApp } from "../../lib/miniVue.esm.js"; > ``` > > I am sure that `miniVue.esm.js` is exist and can use `gf` to jump to this file, however, browser report that > > ``` > GET http://127.0.0.1:8080/lib/miniVue.esm.js net::ERR_ABORTED 404 (Not Found) > ``` > > the same plugin in vscode is work properly, so I guess it is a bug of this plugin https://www.npmjs.com/package/live-server checkout the follwoing
barrettruth commented 2024-02-03 20:00:41 +00:00

@shellRaining. Thanks for the response v0ry as well.

@shellRaining. Thanks for the response v0ry as well.
kxrur commented 2024-02-16 01:31:19 +00:00

Hey there,
I am facing a similar issue when trying to link css files to my html.

If the file is in (or is a child of) the current directory the css will apply to my webpage, however when trying to move up the directory tree (i.e. using ../) the css is no longer applied.

I found a similar issue with the vscode plugin and someone hinted that it may be due to the web root of the live server.

However, I know for a fact that the above (css file out of scope of html) is not an issue in vscode as I have tested it.
So this brings me to wonder how was it configured in vscode and how I could adapt it to this plugin.

Hey there, I am facing a similar issue when trying to link css files to my html. If the file is in (or is a child of) the current directory the css will apply to my webpage, however when trying to move up the directory tree (i.e. using `../`) the css is no longer applied. I found a similar issue with the vscode plugin and someone [hinted](https://github.com/ritwickdey/vscode-live-server/issues/293#issuecomment-886815654) that it may be due to the web root of the live server. However, I know for a fact that the above (css file out of scope of html) is not an issue in vscode as I have tested it. So this brings me to wonder how was it configured in vscode and how I could adapt it to this plugin.
barrettruth commented 2024-02-16 20:52:10 +00:00

@kxrur thanks for the update. how does this work with using live-server via the CLI (can you start it in a different directory or with different arguments and it'll work)? From what you linked, it seems like that could be a configuration error/confusion. Can you provide screenshots/config for this (basic index.html, styles/index.css or something like that) so I can replicate and fix this issue?

@kxrur thanks for the update. how does this work with using `live-server` via the CLI (can you start it in a different directory or with different arguments and it'll work)? From what you linked, it seems like that could be a configuration error/confusion. Can you provide screenshots/config for this (basic `index.html`, `styles/index.css` or something like that) so I can replicate and fix this issue?
kxrur commented 2024-02-17 05:36:12 +00:00

Sure thing! I am pretty new to this so I did not have the courage to go through the various arguments of live-server in the CLI, hopefully this below is eough.

Info

  • Operating System: Linux (Ubuntu 22.04.3 LTS)
  • nvim --version: v0.10.0
  • Node package manager: npm
  • <node-package-manager> --version: 10.2.4
  • live-server --version: 1.2.2

Configuration

  "barrett-ruth/live-server.nvim",
  build = "npm add -g live-server",
  cmd = { "LiveServerStart", "LiveServerStop" },
  config = true,
  keys = {
    { "<leader>cp", "<cmd>LiveServerToggle<cr>", desc = "Start live server" },
  },

Description

given a set-up with the following structure:

.
├── assets
│   └── icon.svg
├── css
│   └── style.css
└── html
    └── index.html

and the following index and style files respectively

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title></title>
    <link href="../css/style.css" rel="stylesheet" />
  </head>
  <body>
    <p>Text</p>
    <img src="../assets/icon.svg" alt="icon" />
  </body>
</html>
p {
  color: pink;
}
img {
  width: 20px;
}
  • Test 1: run LiveServerStart from nvim's command line
    image

  • Test 2: run live-server from a terminal
    image
    -- > chose html
    image

  • Test 3: run cd html/ && live-server from a terminal
    image

  • Test 4: click on 'Go Live' in vscode
    image

Sure thing! I am pretty new to this so I did not have the courage to go through the various arguments of live-server in the CLI, hopefully this below is eough. ### Info - Operating System: Linux (Ubuntu 22.04.3 LTS) - `nvim --version`: v0.10.0 - Node package manager: npm - `<node-package-manager> --version`: 10.2.4 - `live-server --version`: 1.2.2 ### Configuration ```lua "barrett-ruth/live-server.nvim", build = "npm add -g live-server", cmd = { "LiveServerStart", "LiveServerStop" }, config = true, keys = { { "<leader>cp", "<cmd>LiveServerToggle<cr>", desc = "Start live server" }, }, ``` </details> ### Description given a set-up with the following structure: ```bash . ├── assets │   └── icon.svg ├── css │   └── style.css └── html └── index.html ``` and the following index and style files respectively ```html <!doctype html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title></title> <link href="../css/style.css" rel="stylesheet" /> </head> <body> <p>Text</p> <img src="../assets/icon.svg" alt="icon" /> </body> </html> ``` ```css p { color: pink; } img { width: 20px; } ``` * Test 1: run `LiveServerStart` from nvim's command line ![image](https://github.com/barrett-ruth/live-server.nvim/assets/145081482/6942116a-82d0-4031-95d8-0ef6212cbd7a) * Test 2: run `live-server` from a terminal ![image](https://github.com/barrett-ruth/live-server.nvim/assets/145081482/e9e23036-3cc9-43aa-bc9a-dce3631a2b3e) -- > chose html ![image](https://github.com/barrett-ruth/live-server.nvim/assets/145081482/9e256b63-15be-41db-a73c-634b75813e90) * Test 3: run `cd html/ && live-server` from a terminal ![image](https://github.com/barrett-ruth/live-server.nvim/assets/145081482/1741a013-488a-46f7-bc94-0a3ba62bdc33) * Test 4: click on 'Go Live' in vscode ![image](https://github.com/barrett-ruth/live-server.nvim/assets/145081482/9ead5c29-823b-4ab8-89ba-1f249b9f04f1)
barrettruth commented 2024-08-03 22:36:50 +00:00

@shellRaining reopen if still occurring.

@shellRaining reopen if still occurring.
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#3
No description provided.