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 105
npx as the shebang #160
Comments
I think that's a good idea, I was also thinking of something similar. Say you want to try out a library in the repl, but you're not sure you want to install it yet: npx --package library-to-try node const lib = require('library-to-try');
// do stuff with lib As far as I understand it though, this is not how npx was designed, and right now this is not possible either. |
@andreineculau that's because npx doesn't make javascript library APIs available. Only binaries. This works, though, for your specific use case: #!/usr/bin/env npx node@6
console.log(process.versions) |
zkat
added a commit
that referenced
this issue
May 3, 2018
Ref: #160 This makes it so you can do `npx -p lodash node -r lodash` when lodash is not already installed. One big downside of this patch is that because of the semantics of that node feature, NODE_PATH will always be treated as a _fallback_. That is, if you already have one version of lodash installed in a local npm project you're currently in the directory of, you won't be able to override it with the temporary install.
See #180 :) |
zkat
added a commit
that referenced
this issue
May 3, 2018
Fixes: #157 Ref: #160 This makes it so you can do `npx -p lodash node -r lodash` when lodash is not already installed. One big downside of this patch is that because of the semantics of that node feature, NODE_PATH will always be treated as a _fallback_. That is, if you already have one version of lodash installed in a local npm project you're currently in the directory of, you won't be able to override it with the temporary install.
zkat
added a commit
that referenced
this issue
May 3, 2018
Fixes: #153 Ref: #160 This makes it so you can do `npx -p lodash node -r lodash` when lodash is not already installed. One big downside of this patch is that because of the semantics of that node feature, NODE_PATH will always be treated as a _fallback_. That is, if you already have one version of lodash installed in a local npm project you're currently in the directory of, you won't be able to override it with the temporary install.
Closing as a dupe of #153. |
zkat
added a commit
that referenced
this issue
May 4, 2018
Fixes: #153 Ref: #160 This makes it so you can do `npx -p lodash node -r lodash` when lodash is not already installed. One big downside of this patch is that because of the semantics of that node feature, NODE_PATH will always be treated as a _fallback_. That is, if you already have one version of lodash installed in a local npm project you're currently in the directory of, you won't be able to override it with the temporary install.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I'm wondering if there was any thought of having npx as the shebang executor, so that a simple script's dependencies can be inlined in the shebang e.g.
The above complains that it cannot find module 'ajv'.
I didn't dig deeper.
For really short scripts, where the user wouldn't care about the extra seconds in network/disk i/o, this would go a long way.
The text was updated successfully, but these errors were encountered: