Skip to content

fix(locator): fix pnpm path in globalNodeModulesPaths and optimize error handling#760

Open
axuj wants to merge 2 commits intobiomejs:mainfrom
axuj:fix-pnpm-path-in-globalNodeModulesPaths
Open

fix(locator): fix pnpm path in globalNodeModulesPaths and optimize error handling#760
axuj wants to merge 2 commits intobiomejs:mainfrom
axuj:fix-pnpm-path-in-globalNodeModulesPaths

Conversation

@axuj
Copy link

@axuj axuj commented Aug 23, 2025

  • Add shell: true option to safeSpawnSync calls to fix pnpm path
  • Modify error handling logic to use continue instead of return to continue searching other paths

Summary

Fixed pnpm path resolution issue on Windows and improved error handling in global node modules path detection.

Description

This PR addresses a critical issue where spawnSync('npm') fails to execute properly on Windows environments when the shell option is not explicitly set to true. The problem manifests in the globalNodeModulesPaths function where path resolution for pnpm fails due to improper command execution.

Changes made:

  1. Added shell: true option to safeSpawnSync calls to ensure proper execution of npm/pnpm commands on Windows platforms
  2. Modified error handling logic to use continue instead of return to allow searching through alternative paths when one path fails

A test case was used to verify the issue:

import { spawnSync } from 'node:child_process'

const res = spawnSync('npm', ['-h'], {
  env: process.env,
  shell: false, // This fails on Windows
})
console.log(res)

This change ensures cross-platform compatibility and more robust error handling for node modules path detection.

Related Issue

This PR closes #<issue_number>

Checklist

  • I have tested my changes on the following platforms:
    • Windows
    • Linux
    • macOS

…ror handling

- Add shell: true option to safeSpawnSync calls to fix pnpm path
- Modify error handling logic to use continue instead of return to continue searching other paths
@axuj axuj requested review from a team and nhedger as code owners August 23, 2025 15:34
@dyc3 dyc3 changed the title fix(locator): fix pnpm path in globalNodeModulesPaths and optimize er… fix(locator): fix pnpm path in globalNodeModulesPaths and optimize error handling Aug 23, 2025
@nhedger
Copy link
Member

nhedger commented Aug 23, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants