Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Support for the experimental syntax 'optionalChaining' isn't currently enabled, but it is

I've followed the instructions here and here and I've added the following to my package.json

},
"babel": {
    "plugins": [
        "@babel/plugin-proposal-nullish-coalescing-operator",
        "@babel/plugin-proposal-optional-chaining"
    ]
},
"dependencies": {

But I'm still getting the error

Support for the experimental syntax 'optionalChaining' isn't currently enabled

What am I doing wrong here?

like image 698
Mike K Avatar asked Oct 02 '19 19:10

Mike K


People also ask

How do I enable optional chaining?

To enable optional chaining, you need to install a package. At the time of writing, optional chaining is not natively supported in Javascript, it is a new feature introduced in ES2020. Until it is fully adopted we can get all the optional goodness by installing a package!

How do I enable optional chaining in react JS?

Just put in the package. json "react-scripts": "^3.3. 0" and it will work.


Video Answer


2 Answers

Okay I am bit late here, but I can see the question is still active, for those come later:

At the time of writing, optional chaining might not work in NUXT project with node > 12, try using the current LTS version (node 12).

I think the issue might related to one or more dependencies of NUXT but we didn't investigate further, using node 12 resolves the issue for us.

like image 102
Lin Avatar answered Nov 11 '22 06:11

Lin


I had a similar problem, I was using Vue CLI ,the reason is that the scaffolding version is too low (plugins installed separately seem to be ignored), you can check and upgrade your project scaffolding

like image 23
dealloc Avatar answered Nov 11 '22 06:11

dealloc