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

4

7

I am using Windows 10 and I have installed Node.js (with npm) on my local machine. I am trying to follow an instruction which says:

"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!"

Since I am on Windows, I guess "Terminal" means "Command Prompt". So, I have run the "npm install -g live-server" from C:// prompt.

I am now confused about the part where it says "run live-server in your terminal from the root /code folder".

What is the root /code folder?

Mclane answered 16/4, 2020 at 12:20 Comment(1)
Well where are the files you want to serve?Worsen
A
15

In the command prompt, either cmd.com or Windows terminal (yes, the new one actually has the word "terminal" in its name), cd to your project directory (referred to by the docs as the "root" or "code" folder) then type:

live-server

It is literally installed as a command just like cd, dir etc.

The "root" folder or "code" folder is literally the folder where you saved your index.html file.

Alcoran answered 16/4, 2020 at 12:24 Comment(3)
highly recommend the new Windows Terminal app, as it allows unix commandsNonlegal
The word literally is completely unnecessary in your answer.Incomputable
@Incomputable It does make a difference. Sometimes there can be things that behave like commands but not commands in shells such as aliases. However, live-server is installed as an actual command. That means it is literally installed as a command, not just command-likeAlcoran
R
8
  1. Go to your root folder of your project and run
npm install live-server
  1. To start live server run:
npx live-server
Runabout answered 11/2, 2023 at 7:47 Comment(0)
J
1

Default - npm install live server -g

MacOS - sudo npm install live server -g

Here, npm stands for node package manager and helps us to install various packages.We are requesting npm to install the live server package!

The -g tag implies we are installing it globally (meaning it is available everywhere on our computer).

After installation, run live-server.

Joh answered 15/3, 2023 at 5:4 Comment(0)
H
0

Root folder is where your index.html is saved.(from which your code runs). You can use cd ../ to change your folder and get to root. After which you can easily run live server.

Habitant answered 30/4, 2022 at 10:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.