zkat / npx

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

npx'ing a scoped package does not work #67

Closed coderbyheart closed 7 years ago

coderbyheart commented 7 years ago
% npx @coderbyheart/xkcd-password  
npx: installed 19 in 2.583s
command not found: xkcd-password
npx @coderbyheart/xkcd-password  4.93s user 0.35s system 189% cpu 2.794 total

The sourcecode for the package is here: https://github.com/coderbyheart/xkcd-password

The package is published as a scoped package at https://www.npmjs.com/package/@coderbyheart/xkcd-password

It seems npx ignores the scope when executing it.

Running npx from within the package source folder works:

~/git/xkcd-password (git)-[master] % npx @coderbyheart/xkcd-password                                                                                       :(
kerosine brunts shroffs aborally
zkat commented 7 years ago

@coderbyheart this is intentional: npx is meant to execute binaries, not execute arbitrary packages' main.

Just add "bin": "./index.js" and I think that'll work just fine 👍

coderbyheart commented 7 years ago

Duh, my bad! Works now as expected. Thanks!

hon2a commented 6 years ago

@coderbyheart Could you, please, go into detail of how this now works as expected? I ran into the very same problem just now and adding bin did not solve my problem. Then I tried running npx @coderbyheart/xkcd-password and got the same error (command not found).

coderbyheart commented 6 years ago

Hm. Is your setup up to date? It works for me:

m@nanshe ~ % npx @coderbyheart/xkcd-password
npx: installed 19 in 1.686s
cheaply lucency kinsman stagey
hon2a commented 6 years ago

@coderbyheart Thanks for the info, must be my npm version then.

coderbyheart commented 6 years ago

Actually this could fix it for you: https://github.com/coderbyheart/xkcd-password/commit/f68e88123e5168e3b59e4d6ba34157399d89ad93

hon2a commented 6 years ago

@coderbyheart Or I might not have flagged my executable properly at all, we'll never know :) Thanks for the tip!