npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

port-scout

v1.1.2

Published

Finds an available port for http servers and other uses using different searching methods.

Downloads

6

Readme

Port Scout

Port Scout is an easy way to get available ports with different needs.

NPM version Known Vulnerabilities NPM downloads Gitter

Table of contents

Install

To install port-scout to use in your project locally, you can use:

$ npm install port-scout

If you plan on using port-scout as a CLI utility, you can install it globally to have access to the port-scout command anywhere:

$ npm install -g port-scout

Usage

Port Scout is exported as a series of functions so you can just require the port-scout module and use the method you desire to retrieve the port you want.

Note All port scouting methods are async and so will have to be wrapped in an async function call.

const scouter = require('port-scout');

async function main() {
  const webPort = await scouter.web();
}

main();

API

web

Checks common web ports to see what port is available and returns it.

Example:

async function main() {
  const webPort = await scouter.web();
}

main();

random

Tries random ports and returns the first available one. Ports 1-1024 are automatically avoided unless specified.

| param | type | description | default | |----------------- |--------- |----------------------------------------------------------- |--------- | | allowRestricted | boolean | If set to true, this will allow ports 1-1024 to be tried. | false |

Example:

async function main() {
  const randomPort = await scouter.random();
}

main();

range

Checks a provided range of ports for the first available port and returns it.

| param | type | description | default | |------- |-------- |------------------------------------------ |--------- | | start | number | The start of the range of ports to check | | | end | number | The end of the range of ports to check | 65535 |

Example:

async function main() {
  const rangePort = await scouter.range(3050, 3075);
}

main();

CLI Usage

Port can be used as a command line utility to retrieve an available port using one of its various methods and print it to the console like so:

$ port=scout -w

The customize the way ports are retrieved you can use a combination of the flags below:

-w, --web                : Returns a common web server port that can be used, these are normally in the low 3000s or 8080s.
-r, --random             : Returns a random port that can be used at the time of calling this.
-a, --range <start,end>  : Returns the first available port between a start and end value.
-f, --force              : This can be used in conjunction with the random or range flag to override the default rule of not allowing a port between 1 - 1024 to be tested.

Example:

For example, if you would like to get the first available port between 3050 and 3075 you can use:

$ port-scout -r 3050,3075