zkat / npx

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

Ignore nested package.json #165

Open Happy-Ferret opened 6 years ago

Happy-Ferret commented 6 years ago

I'm sure this is a very specific use-case and one that might not be easily achievable with the current way npm works, but I thought I might ask anyways.

Basically, I'm working on a React component library and was hoping to use npx to run a script defined in the root directory's package.json.

Here's the thing that currently makes me struggle though:

Every component of mine consists of a .js, a .css, a README.md and, yes, a package.json file (which contains one single field. main).

The way npm/npx seem to work is that they consider the folder with the package.json in it the root directory. Which means scripts defined in the actual root package.json aren't found and attempting to call an installed node_modules binary actually downloads the particular node module (since the node module doesn't exist in the component directory AKA the directory npx then erroneously considers the root project directory).

Question: Is there a way to ignore those package.json files inside projectName/src/components/componentName and always fall pack to the package.json inside projectName/?

zkat commented 6 years ago

I'm confused by this. Can you put together a repro of what you mean? npx doesn't execute run-scripts, only binaries.

blackmamo commented 5 years ago

I think this may well be a duplicate of this https://github.com/zkat/npx/issues/118