How should node.js npm be used when http-server is installed?

  node.js, question

Jsnpm how should i use http-server when it is installed globally? I created the inde.html in its installation directory, and the browser localhost:8080 can access it. So my project needs to be placed in its installation directory? Or do I need to configure something under my project or use any instructions to start it? I opened cmd to run http-server in my project directory and got an error. Friends from the trouble meeting told me how to use http-server.

1. First, ensure that it is a global installation.

npm install http-server -g

2. For example, one of my directory structures
图片描述
3. Enter the directory and type the command
图片描述
4. Browser access

For example, http://localhost: 8081/index.html or http://localhost:8081/app.js

The react directory here becomes the root directory of the server