Nuxt 2.12.2 throw error on build when trying to use object?.key
.
Module parse failed: Unexpected token (311:25) friendly-errors 10:36:40
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file
So it because babel
in Nuxt configured to support older browsers like IE9
that I did not need in my project.
In another project, I just put .bablelrc
{
"presets": [
["env", {
"targets": {
"browsers": ["last 2 Chrome versions"]
}
}]
]
}
but in Nuxt .bablelrc
are disabled. so how can I make optional chaining operator
work ?
by telling Nuxt to support just modern browsers. or added the @babel/plugin-proposal-optional-chaining