You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
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?
The text was updated successfully, but these errors were encountered:
I'm encountering a very strange error when using
esm
vianode -r esm main.js
.When my
main.js
file contains the following, everything works fine and "foo" is printed:However, when I add an import statement:
Then I get a syntax error:
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:
Any idea what's going on?
The text was updated successfully, but these errors were encountered: