Socket
Socket
Sign inDemoInstall

preferred-pm

Package Overview
Dependencies
21
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    preferred-pm

Detects what package manager was used for installation


Version published
Maintainers
1
Install size
1.11 MB
Created

Package description

What is preferred-pm?

The preferred-pm npm package is designed to detect and suggest the preferred package manager for a given project. It checks for lock files such as package-lock.json, yarn.lock, or pnpm-lock.yaml to determine which package manager was previously used with the project and suggests using the same one for consistency.

What are preferred-pm's main functionalities?

Detecting preferred package manager

This feature allows you to detect the preferred package manager for the current project by analyzing the lock files present in the project directory. The code sample demonstrates how to use the package to find and log the preferred package manager.

const preferredPM = require('preferred-pm');

(async () => {
  const pm = await preferredPM(process.cwd());
  if (pm) {
    console.log(`The preferred package manager is ${pm.name}`);
  } else {
    console.log('No preferred package manager found');
  }
})();

Other packages similar to preferred-pm

Readme

Source

preferred-pm

Returns the preferred package manager of a project

npm version

  • Inside a Yarn workspace, Yarn is preferred.
  • Inside a pnpm workspace, pnpm is preferred.
  • If a package-lock.json is present, npm is preferred.
  • If a yarn.lock is present, Yarn is preferred.
  • If a pnpm-lock.yaml is present, pnpm is preferred.
  • If a bun.lockb is present, Bun is preferred.
  • If a node_modules is present, tries to detect which package manager installed it.

Installation

<pnpm|yarn|npm|bun> add preferred-pm

Usage

'use strict'
const preferredPM = require('preferred-pm')

preferredPM(process.cwd())
    .then(pm => console.log(pm))
//> {name: "npm", version: ">=5"}
  • which-pm - Detects what package manager was used for installation
  • which-pm-runs - Detects what package manager executes the process

License

MIT © Zoltan Kochan

Keywords

FAQs

Last updated on 22 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc