1.1.0 • Published 2 years ago
port-claim v1.1.0
Table of Contents
Install
With npm:
npm install --save port-claimWith yarn:
yarn add port-claimWith pnpm:
pnpm add port-claimUsage
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-claimThen:
# Claim a port
$ port-claim 3000You can also use npx to port-claim without installing:
# Claim a port
$ npx port-claim 3000Example
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
1.1.0
2 years ago