I try to run this simple code in VS Code on Ubuntu:
let user = {};console.log(user?.name);
But I get: "SyntaxError: Unexpected token ." refering to the dot after the question mark.
How can I fix this?
I ran the code in Firefox and also in the terminal. Both works fine. So I assume it's an VS Code problem. My node.js version is v20.16. btw. I installed VS Code and some extensions just one week ago. So I don't think it's related to outdated versions.
What I already did:
- installed the JavaScript and TypeScript Nightly extension
- updated node.js
- in settings I enabled "javascript.suggest.autoImports"
- in settings I enabled "javascript.validate.enable"