dthree / vorpal

Node's framework for interactive CLIs
http://vorpal.js.org
MIT License
5.64k stars 280 forks source link

Can't execute cli when global #160

Closed davidroman0O closed 8 years ago

davidroman0O commented 8 years ago

Hi,

When installing globally and called from an OS X terminal, i got this error message :

/usr/local/bin/mycli: line 1: syntax error near unexpected token(' /usr/local/bin/mycli: line 1: const vorpal = require('vorpal')();'

Do i'm missing something ?

dthree commented 8 years ago

It might be something else in your file. Can you show me the whole fine printout?

alansouzati commented 8 years ago

What is the Node version you have? Can you paste here node --version and npm --version?

davidroman0O commented 8 years ago

Hi,

Sorry i was traveling without internet connexion :/

Vorpal is working when i do node index.json my terminal. But when i try to execute it by installing my helloworld project with npm install -g ./ AND when i type the command (hello) to open it, i got this :

/usr/local/bin/hello: line 1: syntax error near unexpected token(' /usr/local/bin/hello: line 1: const vorpal = require('vorpal')();'

My versions are :

The index.js contains a command hello that type hello world in the terminal. That's all :p

Do i'm missing something?

Thx for answering to this issue, it's cool to see repo with active contributors, i'm sorry for the lack of internet connexion ;)

alansouzati commented 8 years ago

Can you share your entire index.js ? Why do you have `const ?

I have a project using the entire ES6 capabilities and I'm using babel to compile it down to ES5 so I can safely run vorpal in pretty much any Node distribution.

It is still a WIP but I believe it is going to be useful for your project as well:

https://github.com/grommet/grommet-cli

You can run npm run build to create the es5 distribution under bin folder.

davidroman0O commented 8 years ago

Sure, the code is really simple.

const vorpal = require('vorpal')();

vorpal .command('hello', 'do whatever') .action(function(args, callback) { this.log('hello world bro'); callback(); }); vorpal .delimiter('▲ hello') .show();

And it's working with node index.js. Whatever, with varit failed too, with the exact same message (except replace varwith conston the message).

I'll take a look to you grommet-cli

alansouzati commented 8 years ago

can you try to remove this ? '▲ hello'

davidroman0O commented 8 years ago

Done, same error when installed globally `var vorpal = require('vorpal')();'

alansouzati commented 8 years ago

I found the issue 💃

You need to include this at the top of your file:

#!/usr/bin/env node

davidroman0O commented 8 years ago

Ooooh ! Perfect ! It's working. 👍

Thx for the help 😉