Skip to content

Client App using NPM

Here are the steps to create a simple app using npm and adding an HTTP server to serve the index.html file using npm script commands:

Create a new project folder, open terminal, and navigate to the folder.

2. Run the following command to initialize the project and create a package.json file:
npm init

3. Install the http-server package as a dev dependency:
npm install http-server --save-dev

4. Create an index.html file in the project folder.

5. Add a script to the scripts section of the package.json file to start the HTTP server:
"start": "http-server"

6. Start the HTTP server by running the following command:
npm run start

7. Access the app by visiting http://localhost:8080 in your browser.
Now you have a simple app that serves the index.html file using the HTTP server started by the npm script command.

Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.