esm
esm copied to clipboard
Using esm breaks null coalescing operator
I'm encountering a very strange error when using esm
via node -r esm main.js
.
When my main.js
file contains the following, everything works fine and "foo" is printed:
console.log(null ?? "foo");
However, when I add an import statement:
import http from "http";
console.log(null ?? "foo");
Then I get a syntax error:
Simons-MacBook-Pro-2:tribe-server smnzhu$ node -r esm test.js
/Users/smnzhu/Documents/GitHub/tribe/tribe-server/test.js:3
console.log(null ?? "foo");
^
SyntaxError: Invalid or unexpected token
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
What's even weirder is, even when I comment out the import statement, it still throws the same error. Furthermore, when I run these commands in the REPL, there are no issues:
Simons-MacBook-Pro-2:tribe-server smnzhu$ node -r esm
Welcome to Node.js v14.3.0.
Type ".help" for more information.
> import http from "http"
undefined
> console.log(null ?? "foo");
foo
undefined
>
(To exit, press ^C again or ^D or type .exit)
>
Any idea what's going on?
See #866
It just needs an updated acorn build.
Have there been any updates to this? Any idea when this might be fixed?
nope. I'd consider it likely dead.