This repository has been archived by the owner on Jul 6, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 125
bin path in directory without package.json but with node_modules/ #104
Labels
Comments
jridgewell
added a commit
to jridgewell/npx
that referenced
this issue
Oct 19, 2017
This fixes running `npx` inside temporary projects (ones that have a `node_modules` but don't have a `package.json`). `getPrefix()` has useful cases: 1. Finds a path with a `package.json`, returns it. 2. Finds a path with a `node_modules`, returns it. 3. Finds nothing, returns the original path. Cases 1 and 2 return a path that's useful to `npx`, but case 3 doesn't. But, `localBinPath()` confused case 2 and 3 (by stating for a `package.json`), making `npx` only work with case 1. That's no good. This makes cases 1 and 2 distinct from case 3 (it just returns `false` now). And `localBinPath()` no longer has to do any stating to differentiate between paths and `false`, so it's happy. And now `npx` can run without a local `package.json`. Yay! Fixes zkat#104. Fixes babel/babel#4066 (comment).
jridgewell
added a commit
to jridgewell/npx
that referenced
this issue
Oct 19, 2017
This fixes running `npx` inside temporary projects (ones that have a `node_modules` but don't have a `package.json`). `getPrefix()` has useful cases: 1. Finds a path with a `package.json`, returns it. 2. Finds a path with a `node_modules`, returns it. 3. Finds nothing, returns the original path. Cases 1 and 2 return a path that's useful to `npx`, but case 3 doesn't. But, `localBinPath()` confused case 2 and 3 (by stating for a `package.json`), making `npx` only work with case 1. That's no good. This makes cases 1 and 2 distinct from case 3 (it just returns `false` now). And `localBinPath()` no longer has to do any stating to differentiate between paths and `false`, so it's happy. And now `npx` can run without a local `package.json`. Yay! Fixes zkat#104. Fixes babel/babel#4066 (comment).
zkat
pushed a commit
that referenced
this issue
Nov 6, 2017
This fixes running `npx` inside temporary projects (ones that have a `node_modules` but don't have a `package.json`). `getPrefix()` has useful cases: 1. Finds a path with a `package.json`, returns it. 2. Finds a path with a `node_modules`, returns it. 3. Finds nothing, returns the original path. Cases 1 and 2 return a path that's useful to `npx`, but case 3 doesn't. But, `localBinPath()` confused case 2 and 3 (by stating for a `package.json`), making `npx` only work with case 1. That's no good. This makes cases 1 and 2 distinct from case 3 (it just returns `false` now). And `localBinPath()` no longer has to do any stating to differentiate between paths and `false`, so it's happy. And now `npx` can run without a local `package.json`. Yay! Fixes: #104 Fixes: babel/babel#4066 (comment)
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
If I am in a directory with a
node_modules
directory and no package.json,npx
does not find the appropriate binary in my opinion.Example:
Changing the definition of path to allow directories that contain a node_modules directory without a package.json file would be useful because sometimes if a developer wanted to quickly test something without running
npm init
. Also, this would be similar to how node itself does package lookups.The text was updated successfully, but these errors were encountered: