mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-31 13:32:18 -04:00
fix(env): do not create a command shim for the Node.js executable (#3869)
This commit is contained in:
5
.changeset/hungry-pillows-begin.md
Normal file
5
.changeset/hungry-pillows-begin.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-env": patch
|
||||
---
|
||||
|
||||
Do not create a command shim for Node.js, just a symlink to the executable.
|
||||
@@ -1,3 +1,4 @@
|
||||
import { promises as fs } from 'fs'
|
||||
import path from 'path'
|
||||
import { docsUrl } from '@pnpm/cli-utils'
|
||||
import PnpmError from '@pnpm/error'
|
||||
@@ -64,15 +65,18 @@ export async function handler (opts: NvmNodeCommandOptions, params: string[]) {
|
||||
useNodeVersion: nodeVersion,
|
||||
})
|
||||
const src = path.join(nodeDir, process.platform === 'win32' ? 'node.exe' : 'bin/node')
|
||||
const dest = path.join(opts.bin, 'node')
|
||||
const cmdShimOpts = { createPwshFile: false }
|
||||
await cmdShim(src, dest, cmdShimOpts)
|
||||
const dest = path.join(opts.bin, process.platform === 'win32' ? 'node.exe' : 'node')
|
||||
try {
|
||||
await fs.unlink(dest)
|
||||
} catch (err) {}
|
||||
await fs.symlink(src, dest, 'file')
|
||||
try {
|
||||
let npmDir = nodeDir
|
||||
if (process.platform !== 'win32') {
|
||||
npmDir = path.join(npmDir, 'lib')
|
||||
}
|
||||
npmDir = path.join(npmDir, 'node_modules/npm/bin')
|
||||
const cmdShimOpts = { createPwshFile: false }
|
||||
await cmdShim(path.join(npmDir, 'npm-cli.js'), path.join(opts.bin, 'npm'), cmdShimOpts)
|
||||
await cmdShim(path.join(npmDir, 'npx-cli.js'), path.join(opts.bin, 'npx'), cmdShimOpts)
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user