Installation

serve is a Node.js-based tool. To use it, you'll need to have Node.js installed on your system.

Prerequisites

  • Node.js: serve version 14 and later requires Node.js version 14 or higher. You can check your Node.js version by running:
node --version

If you need to use an older version of Node.js, you can install version 13 of serve.

Quickest Method (npx)

The fastest way to use serve without a permanent installation is with npx, which is included with npm (version 5.2+).

Navigate to your project's directory and run:

npx serve

This command will temporarily download and run the latest version of serve, serving the contents of the current directory.

Global Installation

If you plan to use serve frequently across different projects, a global installation is recommended.

You can install serve globally using either npm or pnpm:

Using npm

npm install --global serve

Using pnpm

pnpm add --global serve

Once installed globally, you can run the serve command from any directory on your system.

# Serve the current directory
serve

# Serve a specific folder
serve path/to/your/folder

Verifying the Installation

To confirm that serve has been installed correctly, you can check its version:

serve --version