args icon indicating copy to clipboard operation
args copied to clipboard

User friendly error messages, when running subcommands (bin missing, access error etc)

Open ntwcklng opened this issue 8 years ago • 8 comments

This is maybe just helpful while developing, but when i registered a subcommand with .command()and forgot to npm link and/or add the binary to the package.json we could output a more user friendly error message to prevent issues like these: #69 #46

ntwcklng avatar Apr 16 '17 07:04 ntwcklng

Hi @ntwcklng, just discovered args and I love the balance it strikes between features and simpleness. The implicit relation between the command definition and how the command binary file is called was the only confusing part for me. I think this will also be confusing for (potential) new contributors to a project using args. Instead of needing to npm link would you consider changing the command API to accept a path to the command? This would make the linking unnecessary and the relation explicit.

Siilwyn avatar Apr 04 '18 12:04 Siilwyn

I don't understand, this is from package.json of lib catalog

  "bin": {
    "catalog": "dist/cli/bin/catalog.js",
    "catalog-start": "dist/cli/bin/catalog-start.js",
    "catalog-build": "dist/cli/bin/catalog-build.js"
  },

it uses args and this fails

$ ./node_modules/.bin/catalog build
/myproject/node_modules/args/lib/utils.js:317
      throw err;
Error: spawn catalog-build ENOENT

But if I had catalog build in scripts of package.json adn do npm run nameOfTheScript it will work.

as the lib has all this commands in bin section of packge.json all this binaries will be in ./node_modules/.bin/ so why can't args find catalog-build?

see https://github.com/interactivethings/catalog/issues/408

safareli avatar Apr 25 '18 20:04 safareli

Hey @safareli does this fix your problem: https://github.com/leo/args/issues/46#issuecomment-284367931

ntwcklng avatar Apr 26 '18 05:04 ntwcklng

bin part of package.json is set up properly (see my last comment) not sure how npm link can help, as I just did npm i catalog and after it i expect running ./node_modules/.bin/catalog start to just work.

safareli avatar Apr 26 '18 11:04 safareli

Ah okay, i assumed you've pulled it from github for developing. Why whould you run ./node_modules/.bin/catalog start instead of catalog start?

ntwcklng avatar Apr 26 '18 11:04 ntwcklng

As it's installed locally as dependency of another project. so it's in package.json#dependencies and i do npm i and catalog is installed in ./node_modules/catalog and as it has bin in it's package.json there is also binary files in ./node_modules/.bin/.

safareli avatar Apr 26 '18 12:04 safareli

Can you share the repo or want to debug? Help is appreciated.

ntwcklng avatar Apr 26 '18 12:04 ntwcklng

sure,

https://github.com/f-o-a-m/foam.css/blob/master/package.json#L6 here you can see I have this script "start": "catalog start", If I do npm run start it works fine, but if i do ./node_modules/.bin/catalog start it fails.

safareli avatar Apr 26 '18 12:04 safareli