live-server.nvim
live-server.nvim copied to clipboard
[Bug] can't handle relative path properly
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
Hey, sorry about the issue - can you provide a boilerplate so I can duplicate the error?
Thanks.
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.4live-server --version
: live-server 1.2.2Configuration
use
lazy
and just useconfig = 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 usegf
to jump to this file, however, browser report thatGET 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
@shellRaining. Thanks for the response v0ry as well.
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.
@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?
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 -
Test 2: run
live-server
from a terminal-- > chose html
-
Test 3: run
cd html/ && live-server
from a terminal -
Test 4: click on 'Go Live' in vscode
@shellRaining reopen if still occurring.