zkat / npx

execute npm package binaries (moved)
https://github.com/npm/npx
Other
2.63k stars 105 forks source link

Won't traverse to parents if dir has package.json? #222

Open jnardone opened 5 years ago

jnardone commented 5 years ago

We hoist all our common deps to the top-level parent, as well as common utilities (jest, eslint, pm2, etc.)

However, many of the child folders have their own package.json for one reason or another. (version strings, main: declaration, etc.)

npx won't traverse past the current directory, but only if it has a package.json. (This was reported and then closed in https://github.com/zkat/npx/issues/210)

Example tree:

/package.json
/node_modules
/node_modules/.bin/foo
/packages
/packages/bar
/packages/bar/package.json

I should be able to, in packages/bar, call npx foo and have it resolve. This is expected behavior. But it won't.

If packages/bar does NOT have a package.json, npx foo will resolve to the correct in 2 parents up.