zkat / npx

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

Clarify `it will be installed prior to execution` in readme #122

Open vjpr opened 7 years ago

vjpr commented 7 years ago

From readme:

By default, npx will check whether exists in $PATH, or in the local project binaries, and execute that. If is not found, it will be installed prior to execution.

I was initially confused by this as I thought the installation would be persisted. E.g When I run npx cowsay@1 boo twice, I did not expect it to install twice.

We should make a note that it will be installed prior to *each* execution in a temporary directory.


Also from readme:

Executes either from a local node_modules/.bin, or from a central cache, installing any packages needed in order for to run.

The usage of from a central cache seems misleading, because I would expect it to re-use the cached module if I run npx cowsay@1 boo twice.

zkat commented 7 years ago

This is related to https://github.com/zkat/npx/issues/113.

I'm open to a PR rewording some of these things, but be prepared for word-smithing.

As far as intentions go, the semantics of this feature are such that any time you do npx pkg@latest, it should behave as if you've requested the actual latest version at that point in time. Having previously run npx pkg@latest should not give you a stale installation, even if it was, say, yesterday. There are some optimizations to be done around this (which is what #113 is about), but those optimizations must not break the semantics. They should just be a bit smarter about caching.

The expected usage for npx is that if you have a command you run a lot, it should be actually installed. Preferably in your local project, but a global installation would work, too.

Wilfred commented 6 years ago

@zkat could you clarify how this relates to --no-install? I'm happy to send a PR to clarify the behaviour, but I don't understand what the intended behaviour is here.

$ npx --no-install "commonmark@0.28.1" --version
npx: installed 5 in 1.49s
commonmark.js 0.28.1
$ npx --no-install "commonmark@0.28.1" --version
npx: installed 5 in 1.152s
commonmark.js 0.28.1
$ npx --version
9.7.1

I was surprised to see information about an install on the second npx command.

zkat commented 6 years ago

@wilfred that looks like a bug, innit

Wilfred commented 6 years ago

Okey-doke, opened #156 :)

mattdiamond commented 6 years ago

This seems like a good place to ask: where is the package installed if it isn't found? And is the package deleted afterwards?

zkat commented 6 years ago

@mattdiamond A tmp dir inside ~/.npm/_npx which is removed after execution.