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

Generated .js files don't run in Node.js #16

Closed
ageitgey opened this issue Mar 21, 2016 · 3 comments
Closed

Generated .js files don't run in Node.js #16

ageitgey opened this issue Mar 21, 2016 · 3 comments

Comments

@ageitgey
Copy link

First of all, thanks for all the work on this project!

I tried out Transcript and the end of each generated .js file looks like this:

window ['test'] = test ();

This fails on Node.js because there is no window object when running javascript on the server:

$ node __javascript__/test.js

/Users/ageitgey/Desktop/__javascript__/test.js:977
window ['test'] = test ();
^

ReferenceError: window is not defined

To make the generated code work on Node.js, all you have to do is remove is this:

// Original code
window ['test'] = test ();

// Change to:
test ();

I know your main use case might be to generate .js to run in the browser. But would it be possible to support generating code that doesn't assume there is a window object? Maybe it could be done via an optional parameter if you prefer the current behavior?

@JdeH
Copy link
Collaborator

JdeH commented Mar 22, 2016

I think it's a good idea to make it useable in node.js as well, e.g. in case people want to use it on the desktop instead of CPython for easy access to JS libs.

Will add a command line parameter for this.

@JdeH
Copy link
Collaborator

JdeH commented Mar 22, 2016

-p switch added. Let me know it this works for you.

Kind regards
Jacques

@ageitgey
Copy link
Author

That's great! 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