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

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

5 participants