Install
# use pnpm
$ pnpm install -D @node-kit/which-pm
# use yarn
$ yarn add -D @node-kit/which-pm
# use npm
$ npm install -D @node-kit/which-pm
Usage
use @node-kit/which-pm
in terminal
npx which-pm
# output: pnpm@7.26.1 | null
use import
import { whichPM, whichPMSync } from '@node-kit/which-pm'
whichPM()
// or
whichPMSync()
use require
const { whichPM, whichPMSync } = require('@node-kit/which-pm')
whichPM()
// or
whichPMSync()
API reference
- Usage:
whichPM([cwd, withVersion])
& whichPMSync([cwd, withVersion])
- Parameters:
Param | Description | Type | Optional value | Required | Default value |
---|
cwd | running path | string | - | false | - |
withVersion | return with version | boolean | - | false | true |
declare function whichPM(cwd?: string, withVersion?: boolean): Promise<string | null>
declare function whichPMSync(cwd?: string, withVersion?: boolean): string | null
- simple use
import { whichPM, whichPMSync } from '@node-kit/which-pm'
whichPM().then(path => {
console.log('The package manager is: ', path) // pnpm@7.26.1 | null
})
console.log('The package manager is: ', whichPMSync()) // pnpm@7.26.1 | null
Issues & Support
Please open an issue here.
License
MIT