Conversation
Currently `npx [email protected]` is broken. Running this on my mac I get: ``` Error: csskit binary not found for darwin-arm64 Please ensure the appropriate platform package is installed: npm install csskit-darwin-arm64 ``` The problem is that `npx` will install dependencies "flat". We assume that the binary is located in `csskit`'s `node_modules` directory, but that isn't the case here. For example `npm i -g csskit` will install: - `/Users/<...>/node_modules/csskit/bin/csskit` - `/Users/<...>/node_modules/csskit/node_modules/csskit-darwin-arm64/bin/csskit` While `npx csskit` installs: - `/Users/<...>/node_modules/csskit/bin/csskit` - `/Users/<...>/node_modules/csskit-darwin-arm64/bin/csskit` To fix this, this change incorporates a directory walk instead of a single lookup. Starting from `csskit`'s `bin` directory we check `../node_modules/...` to see if the package is installed there. This means we'll check for e.g.: - `/Users/<...>/node_modules/csskit/node_modules/csskit-darwin-arm64/bin/csskit` - `/Users/<...>/node_modules/node_modules/csskit-darwin-arm64/bin/csskit` - `/Users/<...>/node_modules/csskit-darwin-arm64/bin/csskit` - `/Users/node_modules/csskit-darwin-arm64/bin/csskit` This directory walk means that for the `npm i` case, the first hit is going to be correct - so it shouldn't take any longer to lookup in this case. For the `npx` case, this will likely be the second hit, and so still should take a very small amount of time. The continued directory walk might also help us for other esoteric setups, though it's not strictly necessary (though also, it might be tricky to add sufficient smarts to avoid these extra lookups).
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently
npx [email protected]is broken. Running this on my mac I get:The problem is that
npxwill install dependencies "flat". We assume that thebinary is located in
csskit'snode_modulesdirectory, but that isn't thecase here. For example
npm i -g csskitwill install:/Users/<...>/node_modules/csskit/bin/csskit/Users/<...>/node_modules/csskit/node_modules/csskit-darwin-arm64/bin/csskitWhile
npx csskitinstalls:/Users/<...>/node_modules/csskit/bin/csskit/Users/<...>/node_modules/csskit-darwin-arm64/bin/csskitTo fix this, this change incorporates a directory walk instead of a single
lookup. Starting from
csskit'sbindirectory we check../node_modules/...to see if the package is installed there. This means we'll check for e.g.:
/Users/<...>/node_modules/csskit/node_modules/csskit-darwin-arm64/bin/csskit/Users/<...>/node_modules/node_modules/csskit-darwin-arm64/bin/csskit/Users/<...>/node_modules/csskit-darwin-arm64/bin/csskit/Users/node_modules/csskit-darwin-arm64/bin/csskitThis directory walk means that for the
npm icase, the first hit is going tobe correct - so it shouldn't take any longer to lookup in this case. For the
npxcase, this will likely be the second hit, and so still should take a verysmall amount of time. The continued directory walk might also help us for other
esoteric setups, though it's not strictly necessary (though also, it might be
tricky to add sufficient smarts to avoid these extra lookups).