yeoman / yo

CLI tool for running Yeoman generators
http://yeoman.io
BSD 2-Clause "Simplified" License
3.85k stars 400 forks source link

Generator version is not applied with npx when another version is installed globally #607

Open LazarusX opened 5 years ago

LazarusX commented 5 years ago

Type of issue

Bug?


My environment

Expected behavior

Yeoman chooses the generator installed by npx over that installed globally.

Current behavior

When executing with npx, generator version is not applied when another version is installed globally

Steps to reproduce the behavior

  1. Install Yeoman and a generator globally npm i -g yo generator-generator
  2. Run npx command with another version of generator npx -p yo -p generator-generator@3.0.0 -- yo generator-generator. The globally installed generator (latest) is used instead of 3.0.0
SBoudrias commented 5 years ago

Hey, thanks for the bug report.

The logic for where Yeoman will look for generators is defined in this file https://github.com/yeoman/environment/blob/master/lib/resolver.js#L128 (specifically this function for NPM paths)

I think we'll need to add a relative path aware of the NPX folder structure if we want this to take priority. Interested in sending a PR?