Comments (7)
@stuartpb Everything in this issue has (I believe) been implemented as of [email protected]
. Thanks for all the ideas! Please do keep them coming. I'll close this issue in particular, though. (and if what you described here doesn't work, it might be a bug, and worth fixing).
from npx.
Thanks for the suggestion! This was almost exactly what I was doing already buuuut it works now:
This'll be included when I actually release npx. To be clear: I split out everything after <command>
and it is interpreted entirely by <command>
at that point. Only things left of the command are parsed by npx.
from npx.
👍
Is --
to explicitly signify that the next argument is <command>
implemented?
from npx.
@stuartpb oh. No, not that. I don't think I would do that. The first non-option argument is always interpreted as a command, and it will be used exactly as-is if you provide a -p
option. npx
itself accepts no variadic argument, so the parser is able to disambiguate this easily enough.
Therefore, npx -p $mypackage@$myversion $@
will be interpreted the way you're describing, unless I misunderstood something.
from npx.
The first non-option argument is always interpreted as a command, and it will be used exactly as-is if you provide a
-p
option.npx
itself accepts no variadic argument, so the parser is able to disambiguate this easily enough.
Well, no, because you can have a command with the same name as an option. It's perfectly valid to have a bin script called -c
- it might not be advisable (due to the potential confusion in scenarios just like this), but it can make sense in certain contexts (for instance, for a package that, itself, uses scripts for arguments to the script itself - imagine a project that ran its crispify
script when called as foobar crispify
, then wanted to add foobar -c
as a variant alias for drop-in intercompatibility with a similar tool). Without --
to signal "the next argument is the beginning of the command", there's no way to distinguish this unambiguously.
from npx.
Illustrated:
npx -p foo -c 'require("alert")(1)'
# executes 'require("alert")(1)' in an npm run-script environment
npx -p foo -- -c 'require("alert")(1)'
# runs the script '-c' with 'require("alert")(1)' as its first argument
from npx.
💯
from npx.
Related Issues (20)
- How to tell what binary gets executed?
- Accessing contents of a binary package
- npx -p touch nodetouch gulpfile.js
- --no-install should be default behavior HOT 1
- Won't traverse to parents if dir has package.json?
- Is this project dead? HOT 6
- Scoped packages, with "install" in the title, trigger "npm install"
- TypeError: Cannot read property 'loaded' of undefined
- Feature Request: support --prefix like npm, to run npx in another base directory
- Too many vulnerabilities HOT 4
- `---no-install` also when the package exists
- Cannot find module 'internal/util/types' when doing npm install -g npx
- npx rimraf fails as part of prepare script when publishing
- After removing space in path I'm getting this issue...
- Benefit of this over npm run? HOT 5
- Why doesn't npx work with @vue/cli?
- Webpack-cli postinstall script fails to run
- Minor typo on auto-fallback.js
- is there a way to use npx to run local version of node?
- cannot run "npx @babel/cli" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from npx.