最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Error: Support for the experimental syntax 'optionalChaining' isn't currently enabled, but

programmeradmin5浏览0评论

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?

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?

Share Improve this question edited Oct 2, 2019 at 19:30 Mike K asked Oct 2, 2019 at 19:16 Mike KMike K 6,52117 gold badges75 silver badges144 bronze badges 6
  • Maybe silly question but did you install the packages npm insall/ yarn add? – dreijntjens Commented Oct 4, 2019 at 7:51
  • I have, yes lol – Mike K Commented Oct 4, 2019 at 8:00
  • Are you using webpack? If so could you add the webpack.config.js? – dreijntjens Commented Oct 4, 2019 at 9:10
  • Adding those plugins to my webpack config worked for me in removing that error message. I think instead of adding those plugins to the package.json, try adding it to your webpack config -- under the options key for the babel-loader rule/entry. Another possibility is adding it to your .babelrc file (if you have one in your project). – Venryx Commented Nov 26, 2019 at 11:49
  • Not a direct solution since I can't know what your setup is, but: Search for any @babel/plugin-proposal- across the codebase. It may live in multiple files, sometimes twice in the same file. This has worked for me. – diogo Commented Aug 10, 2020 at 13:56
 |  Show 1 more ment

2 Answers 2

Reset to default 2

Okay I am bit late here, but I can see the question is still active, for those e 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.

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论