react-arborist icon indicating copy to clipboard operation
react-arborist copied to clipboard

Module parse failed: Unexpected token (394:7)

Open tesla-cat opened this issue 2 years ago • 10 comments

Failed to compile.

./node_modules/react-arborist/dist/module.js 394:7
Module parse failed: Unexpected token (394:7)
File was processed with these loaders:
 * ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|     };
| 
>     el?.addEventListener("keydown", cb);
|     return () => {
|       el?.removeEventListener("keydown", cb);

tesla-cat avatar Sep 29 '22 14:09 tesla-cat

I had the same problem. I figured out that webpack was not able to parse/resolve those arrow functions in this package and caused this problem. So removing those arrow function syntax or pass 'react-arborist' to babel loader in webpack config will solve this.

luojinzhang avatar Nov 24 '22 22:11 luojinzhang

What is the environment you're using react-arborist in?

jameskerr avatar Nov 28 '22 23:11 jameskerr

I have Node: 16.15.0 Webpack: 5.5.1 React: 17.0.1 Electron: 11.0.1 Typescript: 4.0.5

luojinzhang avatar Nov 29 '22 06:11 luojinzhang

Do you think if we made the compile target a lower version of JavaScript, that would fix this?

jameskerr avatar Nov 29 '22 17:11 jameskerr

I am not sure really.

luojinzhang avatar Dec 06 '22 01:12 luojinzhang

Are you using "create-react-app"?

jameskerr avatar Dec 07 '22 16:12 jameskerr

Upgrade @babel/preset-env in package.json to the most recent version.

waliurjs avatar Jan 26 '23 17:01 waliurjs

Similar issue here. Not sure what to make of it. image

v3.0.2

Edit: and apparently using the right babel-magic makes the error go away.

heinrich-ulbricht avatar Mar 10 '23 23:03 heinrich-ulbricht

For people who have the same issue delete node_modules and change package.json https://github.com/facebook/create-react-app/issues/9468#issuecomment-694191642

HelloRickey avatar Nov 22 '23 04:11 HelloRickey

I can probably fix this in the way I bundle the app. I need to lower the version of javascript that this package outputs.

jameskerr avatar Dec 12 '23 17:12 jameskerr