M
M
MalGym2021-09-21 19:19:47
webpack
MalGym, 2021-09-21 19:19:47

Why is Webpack swearing at the operator?

There is this piece of code:

let concateUrlSearch = Object.entries(urlHash.split('&').reduce((acc, n) => (
           n = n.match(/(.*)=(.*)/),
           (acc[n[1]] ??= []).push(n[2]),
           acc
         ), {})).map(n => `${n[0]}=${n[1].join('|')}`);


Webpack throws this error. If I remove ??= or replace it with || , then everything works, but not as it should. Help solve it.

ERROR in ./src/js/components/Accordeon.js 68:23
Module parse failed: Unexpected token (68:23)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2021-09-21
@MalGym

If this is in the code, then include babel + preset-env
If this is in the webpack config itself, update the node to 16

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question