Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ntwcklng opened this issue Apr 16, 2017 · 8 comments

Comments

@ntwcklng
Copy link
Collaborator

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

@Siilwyn
Copy link

Siilwyn commented Apr 4, 2018

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.

@safareli
Copy link

safareli commented Apr 25, 2018

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 interactivethings/catalog#408

@ntwcklng
Copy link
Collaborator Author

Hey @safareli does this fix your problem: #46 (comment)

@safareli
Copy link

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.

@ntwcklng
Copy link
Collaborator Author

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?

@safareli
Copy link

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/.

@ntwcklng
Copy link
Collaborator Author

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

@safareli
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants