Skip to content

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

Open
ageitgey opened this Issue · 0 comments

1 participant

@ageitgey

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.