Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Using esm breaks null coalescing operator #879

Open
synzhu opened this issue May 24, 2020 · 4 comments
Open

Using esm breaks null coalescing operator #879

synzhu opened this issue May 24, 2020 · 4 comments

Comments

@synzhu
Copy link

synzhu commented May 24, 2020

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?

@bsian03
Copy link

bsian03 commented Jun 3, 2020

See #866

@jsg2021
Copy link
Contributor

jsg2021 commented Jul 8, 2020

It just needs an updated acorn build.

@CITguy
Copy link

CITguy commented Jan 6, 2022

Have there been any updates to this? Any idea when this might be fixed?

@jsg2021
Copy link
Contributor

jsg2021 commented Jan 6, 2022

nope. I'd consider it likely dead.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants