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

Issues with 2.7.1 when using sub commands #372

Closed
AdamMagaluk opened this issue Mar 12, 2015 · 8 comments
Closed

Issues with 2.7.1 when using sub commands #372

AdamMagaluk opened this issue Mar 12, 2015 · 8 comments
Assignees

Comments

@AdamMagaluk
Copy link

Sub commands are not working on the lastest, was working in 2.6.0.

Running node cli works but node cli subcommand fails with the error below.

fs.js:691
  return binding.lstat(pathModule._makeLong(path));
                 ^
Error: ENOENT, no such file or directory '/commander-test/cli'
@zhiyelee
Copy link
Collaborator

Could u provide more detail information? thx

@AdamMagaluk
Copy link
Author

See files below, i have a base cli.js file and a subcommand cli-stacks.js breaks on the latest release when running node cli stacks.

node cli -h both 2.7.1 and 2.6.0 prints help message showing stacks command and top level options.

2.6.0

λ: node cli stacks -h

  Usage: cli-stacks [options] [command]


  Commands:

    create [name]   install one or more packages
    delete [query]  search with optional query
    help [cmd]      display help for [cmd]

  Options:

    -h, --help  output usage information

2.7.1

λ: node cli stacks -h

fs.js:691
  return binding.lstat(pathModule._makeLong(path));
                 ^
Error: ENOENT, no such file or directory '/Users/ApigeeCorporation/Software/commander-test/cli'
    at fs.lstatSync (fs.js:691:18)
    at exports.readlinkSync (/Users/ApigeeCorporation/Software/commander-test/node_modules/commander/node_modules/graceful-readlink/index.js:5:7)
    at Command.executeSubCommand (/Users/ApigeeCorporation/Software/commander-test/node_modules/commander/index.js:472:14)
    at Command.parse (/Users/ApigeeCorporation/Software/commander-test/node_modules/commander/index.js:443:17)
    at Object.<anonymous> (/Users/ApigeeCorporation/Software/commander-test/cli.js:7:4)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

cli.js

var program = require('commander');

program
  .version('0.0.1')
  .option('-C, --chdir <path>', 'change the working directory')
  .command('stacks [cmd]', 'install one or more packages')
  .parse(process.argv);

cli-stacks.js

var program = require('commander');
program
  .command('create [name]', 'install one or more packages')
  .command('delete [query]', 'search with optional query')
  .parse(process.argv);

@ghost
Copy link

ghost commented Mar 16, 2015

I'm experiencing the same issue on linux, on windows the sub command is found. I'm getting the following error:

clitest-install(1) does not exist, try --help

Another issue - list coercion function not working, under 2.6.0 working

@AdamMagaluk
Copy link
Author

Issue i'm seeing stems from 154fb8b appears your not calling node sub-command anymore but directly calling sub-command. For my code this means removing the .js extension and making them executable with the typical #!/usr/bin/env node, or pin the commander version to v2.6.0 the latter is probably what i'll stick with.

@zhiyelee zhiyelee self-assigned this Mar 16, 2015
@adius
Copy link

adius commented Mar 23, 2015

I'm having the same issue!

@zhiyelee
Copy link
Collaborator

zhiyelee commented Apr 3, 2015

@AdamMagaluk yep, I will find a way to fix this. You can add #!/usr/bin/env node simply(command will handle the .js itself) OR pin to v2.6.0 before the bug get fixed. Sorry for that.

@zhiyelee
Copy link
Collaborator

zhiyelee commented Apr 3, 2015

@AdamMagaluk yep, u are right. I am working on this bug now. Hope to release a patch version later.

@zhiyelee zhiyelee mentioned this issue Apr 3, 2015
rrthomas pushed a commit to rrthomas/commander.js that referenced this issue Apr 8, 2015
fix the bug discussed in tj#372
Also merge the `execArg` change in tj#305, thx @DigitalIO
wovalle added a commit to wovalle/cloudman-cli that referenced this issue Nov 30, 2015
@yordis
Copy link

yordis commented Feb 7, 2018

Just for leave a note about this.

I was using the git style and because I didn't use .js when I called the file with node it gave me this error

node bin/npm-packager <--- no extension, this fails

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

No branches or pull requests

4 participants