### Install serve globally Source: https://github.com/vercel/serve/blob/main/readme.md Installs the 'serve' package globally, allowing it to be used as a command-line tool. ```bash > npm install --global serve ``` -------------------------------- ### Project File Structure Source: https://github.com/vercel/serve/blob/main/contributing.md The file structure of the 'serve' project. ```sh serve ├── config │ └── husky │ ├── _ │ └── pre-commit ├── media │ ├── banner.png │ └── listing-ui.png ├── source │ ├── utilities │ │ ├── cli.ts │ │ ├── config.ts │ │ ├── http.ts │ │ ├── logger.ts │ │ ├── promise.ts │ │ └── server.ts │ ├── main.ts │ └── types.ts ├── contributing.md ├── license.md ├── package.json ├── pnpm-lock.yaml ├── readme.md └── tsconfig.json ``` -------------------------------- ### Committing changes Source: https://github.com/vercel/serve/blob/main/contributing.md Git commands to stage and commit local changes. ```sh > git add this/folder that/file > git commit --message 'commit-message' ``` -------------------------------- ### Create a new branch Source: https://github.com/vercel/serve/blob/main/contributing.md Command to create a new branch for making changes. ```sh > git switch --create branch-name ``` -------------------------------- ### Linting and Testing Source: https://github.com/vercel/serve/blob/main/contributing.md Commands to run the linter and tests, and to automatically fix lint issues. ```sh pnpm lint pnpm test pnpm lint --fix ``` -------------------------------- ### Pushing changes to your fork Source: https://github.com/vercel/serve/blob/main/contributing.md Git command to push committed changes to a remote branch. ```sh > git push -u origin branch-name ``` -------------------------------- ### Running the CLI tool in development Source: https://github.com/vercel/serve/blob/main/contributing.md Command to run the CLI tool, which automatically re-runs on code changes. ```sh pnpm develop ``` -------------------------------- ### Rebasing your branch to include upstream changes Source: https://github.com/vercel/serve/blob/main/contributing.md Git commands to fetch changes from the upstream main branch and rebase the current branch onto it. ```sh > git fetch upstream main > git rebase upstream/main ``` -------------------------------- ### Show help for serve Source: https://github.com/vercel/serve/blob/main/readme.md Displays a list of all available options and commands for the 'serve' tool. ```bash > serve --help ``` -------------------------------- ### Use serve-handler as middleware Source: https://github.com/vercel/serve/blob/main/readme.md Demonstrates how to use the 'serve-handler' package as middleware in a Node.js HTTP server. ```javascript const handler = require('serve-handler'); const http = require('http'); const server = http.createServer((request, response) => { // You pass two more arguments for config and middleware // More details here: https://github.com/vercel/serve-handler#options return handler(request, response); }); server.listen(3000, () => { console.log('Running at http://localhost:3000'); }); ``` -------------------------------- ### Serve a specific folder Source: https://github.com/vercel/serve/blob/main/readme.md Executes the 'serve' command to serve the contents of a specified folder. ```bash > serve folder-name/ ``` -------------------------------- ### Run serve in the current directory Source: https://github.com/vercel/serve/blob/main/readme.md Executes the 'serve' command in the current directory to serve its contents. ```bash > serve ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.