Unexpected token while running node example
Hello, I try to run the nodejs example found here https://www.transcrypt.org/docs/html/installation_use.html 2.5. Compiling for node.js And get unexpected token error on node nodejs_demo.js command:
import { AssertionError, AttributeError, BaseException, DeprecationWarning, Exception, IndexError, IterableError, KeyError, NotImplementedError, RuntimeWarning, StopIteration, UserWarning, ValueError, Warning, JsIterator, PyIterator, Terminal, add, and, call, class, envir, eq, floordiv, ge, get, getcm, getitem, getslice, getsm, gt, i, iadd, iand, idiv, ijsmod, ilshift, imatmul, imod, imul, in, init, ior, ipow, irshift, isub, ixor, jsUsePyNext, jsmod, k, kwargtrans, le, lshift, lt, matmul, mergefields, mergekwargtrans, mod, mul, ne, neg, nest, or, pow, pragma, proxy, pyUseJsNext, rshift, setitem, setproperty, setslice, sort, specialattrib, sub, super, t, terminal,
SyntaxError: Unexpected token { at new Script (vm.js:85:7) at createScript (vm.js:266:10) at Object.runInThisContext (vm.js:314:10) at Module._compile (internal/modules/cjs/loader.js:698:28) at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10) at Module.load (internal/modules/cjs/loader.js:630:32) at tryModuleLoad (internal/modules/cjs/loader.js:570:12) at Function.Module._load (internal/modules/cjs/loader.js:562:3) at Function.Module.runMain (internal/modules/cjs/loader.js:801:12) at internal/main/run_main_module.js:21:11
Any idea?
Regards
I looked at this a bit and it seems the last commit with working nodejs support was 3c54b816. However, to use that version, I found I needed to patch a variable name to avoid the python 3 reserved word "async".
See https://stackoverflow.com/a/39436580/797390 - NodeJS doesn't allow this import syntax by default.
I followed the instructions given in that answer and managed to run current master (https://github.com/QQuick/Transcrypt/commit/a4c7e044b352d6200e5ea3ec6000248a243dfd91) with Node 10.21 (after changing the extension to .mjs)