# use pnpm
$ pnpm install -D @node-kit/pnpm-workspace-root
# use yarn
$ yarn add -D @node-kit/pnpm-workspace-root
# use npm
$ npm install -D @node-kit/pnpm-workspace-root
use import
import { pnpmWorkspaceRoot, pnpmWorkspaceRootSync } from '@node-kit/pnpm-workspace-root'
pnpmWorkspaceRoot()
// or
pnpmWorkspaceRootSync()
use require
const { pnpmWorkspaceRoot, pnpmWorkspaceRootSync } = require('@node-kit/pnpm-workspace-root')
pnpmWorkspaceRoot()
// or
pnpmWorkspaceRootSync()
- Usage:
pnpmWorkspaceRoot(cwd)
&pnpmWorkspaceRootSync(cwd)
- Parameters:
Param | Description | Type | Optional value | Required | Default value |
---|---|---|---|---|---|
cwd | running path | string |
- | false |
- |
- Types:
declare function pnpmWorkspaceRoot(cwd?: string): Promise<string | null>
declare function pnpmWorkspaceRootSync(cwd?: string): string | null
- Demos:
- simple use
import { pnpmWorkspaceRoot, pnpmWorkspaceRootSync } from '@node-kit/pnpm-workspace-root'
pnpmWorkspaceRoot().then(path => {
console.log('The pnpm workspace root is: ', path) // /Users/user/path/of/package/root or null
})
console.log('The pnpm workspace root is: ', pnpmWorkspaceRootSync()) // /Users/user/path/of/package/root or null
Please open an issue here.