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

@lerepo/detect-pm-cli

v0.4.3

Published

CLI to detect which package manager is being used.

Downloads

16

Readme

Detect which package manager is being used

This is a library and a cli to automatically detect which package manager is being used in the current project. The project can be a single workspace or a multi-workspace project.

Detected package managers are:

  • npm
  • yarn (v1)
  • yarn berry (v2)
  • pnpm

CLI Usage

The easiest way to invoke the CLI with zero impact on the project is to run it through yarn dlx or npx. For example:

$ yarn dlx -p @lerepo/detect-package-manager-cli detect-pm
yarn 2.1.1

$ yarn dlx -p @lerepo/detect-package-manager-cli detect-pm --help
Detect installed or used package managers.

Usage:

$ detect-pm [--preference,-p #0] [--cwd #0] [--json] [--installed]

Details:

This command will detect the package manager used in the workspace/project. It
used any available `engines` section in the package manifests or package manager
specific files in the project hierarchy to identify the package manager. If no
such information is available in the current working directory, it crawls the
hierarchy until it finds the root project or it reaches the root of the
filesystem. To set the starting working directory to a different value from the
current one, you can use the `--cwd` option. If the `--installed` option is set,
it will instead detect the installed package managers in the environment. If you
want the output of the command to be in new-line-delimited JSON, set the
`--json` option. The command may find presence of multiple package managers in
the project or definitive choice in the package manifests. In such case, it will
prefer the package managers in the following order `yarn > pnpm > npm`. To
change the preference order, use the `--preference,-p` option (multiple times to
set multiple preferences).

Examples:

Detect using all default options
  $ detect-pm

Detect and output the result in json format
  $ detect-pm --json

Detect and with specific preferences
  $ detect-pm -p pnpm -p yarn

Detect installed package managers
  $ detect-pm --installed