Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullish coalescing (??) causes SyntaxError #909

Open
bolivier opened this issue Dec 8, 2021 · 4 comments
Open

Nullish coalescing (??) causes SyntaxError #909

bolivier opened this issue Dec 8, 2021 · 4 comments

Comments

@bolivier
Copy link

bolivier commented Dec 8, 2021

I'm on Node 16.13.0, and if I run a script with -r esm, I get a syntax error that isn't present when running without it.

Reproduceable example:

This does not run.

// test.js
import { h } from './test2';
console.log(undefined ?? h);

// test2.js
export const h = "hi";

This runs.

// test.js
const { h } = require('./test2');
console.log(undefined ?? h);

// test2.js
module.exports = {
  h: 'hi'
};

The error I see reads

/proj/test.js:2
console.log(undefined ?? h);
                       ^

SyntaxError: Invalid or unexpected token
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
@blakethepatton
Copy link

Can confirm.

@nbrdx
Copy link

nbrdx commented May 6, 2022

Also confirming the problem, using the same node version

@TLovers
Copy link

TLovers commented Jul 16, 2022

Use a `? . 'will also get syntax errors
SyntaxError: Invalid or unexpected token

@veeramarni
Copy link

I used chakra-ui and when starting the backend server which uses SSR, it fails with this error in Node 16. This need to fixed in esm

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

No branches or pull requests

5 participants