Files
pnpm/pkg-manager/plugin-commands-installation/src/nodeExecPath.ts
Josh Goldberg ✨ ee429b300b feat: expanded missing command error, including 'did you mean' (#6496)
close #6492

Co-authored-by: Zoltan Kochan <z@kochan.io>
2023-05-15 03:22:26 +03:00

15 lines
449 B
TypeScript

import { promises as fs } from 'fs'
import which from '@pnpm/which'
export async function getNodeExecPath () {
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
}
}