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

Error on Hash-Bang #49

Open
kobezzza opened this issue Sep 11, 2014 · 5 comments
Open

Error on Hash-Bang #49

kobezzza opened this issue Sep 11, 2014 · 5 comments

Comments

@kobezzza
Copy link

#!/bin/bash
function foo() {
}

Error:

Error: Line 1: Unexpected token ILLEGAL
@raiden-dev
Copy link
Contributor

Scripts starting with shebang should be invoked directly from shell, not through node.js.
You are getting an error because /bin/bash is not a valid interpreter for JavaScript.
Try something like #!/usr/bin/env node and look for details about using shebang in general and especially for node.

@kobezzza
Copy link
Author

Scripts starting with shebang should be invoked directly from shell, not through node.js.

Yes, but here is something else: the code is not transpiled - es6-transpiler error.

console.es6

#!/usr/bin/env node

/* my console app */

https://github.com/visionmedia/jade/blob/master/bin/jade.js

@raiden-dev
Copy link
Contributor

Why it should be transpiled? It is not a valid JS at all. Transpiler gives a proper error, cause you can not do tricks like this. Transpile your script first and then use transpiled output to make a shell script with a shebang.

@kobezzza
Copy link
Author

This could be done optionally, for example

//#!/usr/bin/env node

/* my CLI app */
es6-transpiler myApp.es6 --sha-bang > myApp.js

->

#!/usr/bin/env node

/* my CLI app */

Why not? It is more convenient than writing wrapper.

@raiden-dev
Copy link
Contributor

Such things have no relation to JavaScript. You not blames browsers that throws an exception for invalid code and you can't blame transpiler for the same reasons. You should write the wrapper cause it is out of transpiler's responsibility zone.

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

2 participants