Skip to content

fix: use globbySync to resolve PNPM global node_modules paths#692

Merged
mshima merged 2 commits intoyeoman:mainfrom
phishbacon:fix_pnpm_global_node_module_path_resolution
Dec 19, 2025
Merged

fix: use globbySync to resolve PNPM global node_modules paths#692
mshima merged 2 commits intoyeoman:mainfrom
phishbacon:fix_pnpm_global_node_module_path_resolution

Conversation

@phishbacon
Copy link
Copy Markdown
Contributor

@phishbacon phishbacon commented Dec 13, 2025

Fixes #693

Purpose of this pull request?

  • Documentation update
  • Bug fix
  • Enhancement
  • Other, please explain:

What changes did you make?

Switched to using globbySync when pushing all pnpm node_module directories to paths array. The global/*/node_modules path was failing this existsSync check as the directory doesn't actually exist and so none of the pnpm installed generators could be found

if (!existsSync(root) || (!lstatSync(root).isDirectory() && !lstatSync(root).isSymbolicLink())) {
      continue;

Copy link
Copy Markdown
Contributor

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks for hopping onto a fix! I confirmed locally that e.g. /Users/josh/Library/pnpm/global/5/node_modules does include the generator after pnpm i -g generator-office.

This area is finnicky and new, so we should definitely hear from >=1 of @mshima and @UlisesGascon for review.

onlyDirectories: true,
suppressErrors: true,
absolute: true,
} as GlobbyOptions).map(modulesPath => resolve(pnpmHome, modulesPath)),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Cleanup] Nit: unlike the other uses, this one doesn't need an assertion:

Suggested change
} as GlobbyOptions).map(modulesPath => resolve(pnpmHome, modulesPath)),
}).map(modulesPath => resolve(pnpmHome, modulesPath)),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome thanks for the review. I removed the assertion. I want to add that I've tested on ubuntu and windows
after installing generator-office globally with pnpm and running yo with yeoman-environment linked with my local changes.
on windows:

PS C:\Users\christian\development\yo> echo $env:PNPM_HOME
C:\Users\christian\AppData\Local\pnpm
PS C:\Users\christian\development\yo> node .\lib\cli.js --generators
Available Generators:

  office

PS C:\Users\christian\development\yo> pnpm list -g
Legend: production dependency, optional only, dev only

C:\Users\christian\AppData\Local\pnpm\global\5

dependencies:
generator-office 3.0.2

on ubuntu (wsl):

christian@chrisPC:~/development/yo$ echo $PNPM_HOME
/home/christian/.local/share/pnpm
christian@chrisPC:~/development/yo$ node lib/cli.js --generators
Available Generators:

  office

christian@chrisPC:~/development/yo$ pnpm list -g
Legend: production dependency, optional only, dev only

/home/christian/.local/share/pnpm/global/5

dependencies:
generator-office 3.0.2

onlyDirectories: true,
suppressErrors: true,
absolute: true,
}).map(modulesPath => resolve(pnpmHome, modulesPath)),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are requesting absolute paths, pnpmHome in resolve should not be required.

Suggested change
}).map(modulesPath => resolve(pnpmHome, modulesPath)),
}).map(modulesPath => resolve(modulesPath)),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct. It is not required. I removed pnpmHome from resolve and repeating the above tests we are able to find my pnpm globally installed generators
windows

PS C:\Users\christian\development\yo> node .\lib\cli.js --generators
Available Generators:

  office

ubuntu (wsl)

christian@chrisPC:~/development/yo$ node lib/cli.js --generators
Available Generators:

  office

@mshima mshima merged commit 4317fef into yeoman:main Dec 19, 2025
18 checks passed
@phishbacon phishbacon deleted the fix_pnpm_global_node_module_path_resolution branch December 20, 2025 00:18
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.

yo unable to find generators installed with pnpm

4 participants