npx icon indicating copy to clipboard operation
npx copied to clipboard

Ignore nested package.json

Open Happy-Ferret opened this issue 6 years ago • 2 comments

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/?

Happy-Ferret avatar Mar 21 '18 08:03 Happy-Ferret

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

zkat avatar May 03 '18 21:05 zkat

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

blackmamo avatar Jan 04 '19 15:01 blackmamo