Skip to content

Cannot fork() javascript files when run with 'coffee' command #2523

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

Closed
ashtuchkin opened this issue Aug 29, 2012 · 2 comments
Closed

Cannot fork() javascript files when run with 'coffee' command #2523

ashtuchkin opened this issue Aug 29, 2012 · 2 comments

Comments

@ashtuchkin
Copy link

# index.coffee
{fork} = require "child_process"

fork("child.js")
// child.js
var a = 0;
$ coffee index.coffee
SyntaxError: In child.js, reserved word "var" on line 1
    at SyntaxError (unknown source)
    at Lexer.exports.Lexer.Lexer.error (/home/ubuntu/testrequire/node_modules/coffee-script/lib/coffee-script/lexer.js:682:13)
    ...

The error message comes from the child process, which is exec-ed as coffee child.js.

Seems that the problem is in process.execPath, see:
https://github.com/joyent/node/blob/master/lib/child_process.js#L444
https://github.com/jashkenas/coffee-script/blob/master/src/command.coffee#L79

So, in current state, it is impossible to fork javascript modules when using coffee command.

Seems that it's also related to #1303

Context: From a coffeescript project, I'm require-ing a javascript module that forks a new node process and knows nothing about coffee.

@jashkenas
Copy link
Owner

I don't really see why we should be resetting process.execPath ... so I'll remove that line, which should fix your problem.

@TrevorBurnham -- let me know if there was a good reason why it's there.

@ashtuchkin
Copy link
Author

Confirmed the fix. Thanks!

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

2 participants