在 Node.js 和 npm 安装后如何 运行 live 服务器

How to run live server after Node.js and npm installation

我正在使用 Windows 10,并且我已经在我的本地计算机上安装了 Node.js(使用 npm)。我正在尝试按照说明进行操作:

"Once node.js and npm are installed, run the following command in your terminal.

npm install -g live-server

This will install live-server⁵, a simple static server that has live reload built-in. To
start your server, run live-server in your terminal from the root /code folder —
it will even open a new browser window for you!"

因为我在 Windows,我猜 "Terminal" 意味着 "Command Prompt"。所以,我有 运行 来自 C:// 提示符的“npm install -g live-server”。

我现在对 "run live-server in your terminal from the root /code folder" 的部分感到困惑。

什么是root /code folder

在命令提示符中,cmd.com 或 Windows 终端(是的,其名称中的 new one actually has the word "terminal"),cd 到您的项目目录(由文档作为 "root" 或 "code" 文件夹)然后键入:

live-server

它就像cddir等一样作为命令安装

"root" 文件夹或 "code" 文件夹实际上就是您保存 index.html 文件的文件夹。

根文件夹是保存您的 index.html 的地方。(您的代码 运行 就是从那里保存的)。您可以使用 cd ../ 更改您的文件夹并进入根目录。之后您就可以轻松 运行 在线服务器了。