Invalid Path in liveServer settings root settings Live
author: Nathannie
date: 2022年6月22日15:56:08
问题背景
环境参数:
在vscode编写网页,使用插件 Live Server,在网页文件中,鼠标右键选择【Open with Live Server】,弹出提示框,并未跳转到浏览器页面。
图1-鼠标右键选项界面
报错信息
报错内容:Invalid Path in liveServer settings root settings Live Server will serve from workspace root
报错截图:
图2-报错 提示框
问题分析
一个项目可以有一个单独的vscode配置,结构如下。
project
|——.vscode
|——settings.json
而当前情况是在c盘桌面创建一个文件夹,并创建.html
文件用于测试。live server采用的是默认root
配置,而不是项目的设置。因此需要修改live server的root
配置,使得每一个项目都有各自的root
配置。
问题解决
参考github上一个回答:
@cohn17 I had some issues too. What I did was:
引用
- Create a folder under the root of the site, called
.vscode
- Add a file there, called
settings.json
Edit the file and add the following:
引用{ "liveServer.settings.root": "/dist" }
引用
(dist
being the root folder I want the liveserver to know about)
引用
Then I actually had to edit the global settings.json:
引用- CTRL+SHIFT+P and type "Preferences".
- Search for "liveserver" and click "Edit in settings.json"
引用
引用- I then added the same code inside my global settings.json:
引用
引用- Then launched liveserver, killed it, removed the setting in the global settings.json and then relaunched the server.
引用
From now on, liveserver seems to follow whatever is written in the /.vscode/settings.json - file. Perhaps a bug in vscode?
引用
⚠️ 注意: 修改为liveServer.settings.root: "/dist"
后,当前演示的情况,点击【Open with Live Server】,后端口号不断的修改并且伴随着提示框不断闪烁。猜测可能是当前系统端口号不足,live Server正在寻找可用端口导致的。
"liveServer.settings.port": 3248
相关参考
catchFault
The purpose of this column is to record the problems encountered in programming and give solution...
推荐阅读
VSCode 格式化哲学
当我们说「团队需要统一的代码样式」,大家都没有什么反对意见;但当问题变为「统一成什么样式?」时,大家的声音就嘈杂了起来。人们对于特定的编码方式很抵触,没有人喜欢花时间这样写代码,没人愿意接受别人的...
Cheri赞 2阅读 848
vscode 关闭顶部搜索栏
不知道从什么时候起,vscode 顶部多了一个搜索栏占据空间不说,还没什么吊用怎么关闭呢?在顶栏右键一下,然后取消『命令中心』就行参考: VSCode 顶部出现常驻搜索栏
ponponon阅读 1.1k
vscode日常插件
Chinese (Simplified) Language Pack for Visual Studio Codevscode中文(简体)语言包Auto rename tag自动重命名标签CSS Peek能够查看CSS ID和类的字符串作为HTML文件中相应的CSS定义Document This添加注释块ES7...
稀饭52阅读 986
[TIL] 如何使用 hex editor (二进制编辑器)修改游戏存档
在游戏没有进行特别混淆的的情况下这种方式能很轻松修改存档,对付一些没有现成修改器小众游戏很方便。当然如果能用 CE 之类的内存修改器也很好,但我是在 linux 中用 wine 跑的游戏,估计想用 CE 还要好一番折腾...
AlanZhang阅读 950
12月更新 | Visual Studio Code Python
我们很高兴地宣布,2022年12月发布的适用于 Visual Studio Code Python 和 Jupyter 扩展现已推出!此版本包括以下改进:Pylance 自动缩进 预览:浏览器中运行与调试 Python社区提供新扩展:Ruff如果您有兴趣,可...
微软技术栈阅读 871
visual studio code配置
需要安装的插件GitHub Darkvscode-iconsprettierpython {代码...}
DEFAULT阅读 815
VS Code 将推出更多 AI 功能给 Java 开发者
大家好,欢迎来到我们的二月更新!我们将为您带来与 JUnit 5 并行测试相关的新功能以及用于 Spring Boot Dashboard 的过滤功能。另外,OpenAI 和 ChatGPT 是最近的热点,所以在 GitHub Copilot 方面也有一些令人...
微软技术栈赞 1阅读 308
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。