mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-13 12:49:11 -04:00
15 lines
466 B
TypeScript
15 lines
466 B
TypeScript
import { promises as fs } from 'fs'
|
|
import which from '@pnpm/which'
|
|
|
|
export async function getNodeExecPath (): Promise<string> {
|
|
try {
|
|
// The system default Node.js executable is preferred
|
|
// not the one used to run the pnpm CLI.
|
|
const nodeExecPath = await which('node')
|
|
return fs.realpath(nodeExecPath)
|
|
} catch (err: any) { // eslint-disable-line
|
|
if (err['code'] !== 'ENOENT') throw err
|
|
return process.env.NODE ?? process.execPath
|
|
}
|
|
}
|