1.1.0 • Published 4 months ago

port-claim v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Table of Contents

Install

With npm:

npm install --save port-claim

With yarn:

yarn add port-claim

With pnpm:

pnpm add port-claim

Usage

API

claimPort(portNumber: number): Promise

  • Takes a port number as input.
  • Checks if the port is in use (with detect-port).
  • If the port is already in use, kills the process using it (with kill-port).
  • Returns a promise that resolves when the port is successfully claimed, or rejects with an error if the process fails.

CLI

You can use port-claim as a global package.

Install the package globally:

$ npm install -g port-claim
# OR with yarn
$ yarn global add port-claim
# OR with pnpm
$ pnpm add -g port-claim

Then:

# Claim a port
$ port-claim 3000

You can also use npx to port-claim without installing:

# Claim a port
$ npx port-claim 3000

Example

example usage in a package.json pre script

  "scripts": {
    "predev": "port-claim 3000",
    "dev": "nuxt dev"
  },

Contributing

Got an idea for a new feature? Found a bug? Contributions are welcome! Please open up an issue or make a pull request.

License

MIT © @jasenmichael