-1

I am following simple tutorials like https://github.com/YaroslavW/react-min-setup-abc to create a new React application from scratch (using webpack 4 and babel 7 instead of create-react-app from react-scripts).

I am getting the same error as ReactJS Module build failed: SyntaxError: Unexpected token - ReactDOM.render (Sorry for possible duplicate but none of the solutions from this thread are working for me).

SyntaxError: C:\...\src\index.js: Unexpected token (7:2)

   5 |
   6 | ReactDOM.render(
>  7 |   <div>{title}</div>,
     |   ^
   8 |   document.getElementById('app')
   9 | );

Seems that this repo was working fine but suddenly became broken. I haven't done any changes after pulling from the github. Many tutorials also lead to the same code and the same error.

Seems the solution should be adding @babel/preset-react to the .babelrc file but it is already there in the repo.

Are new versions of the toolset not compatible with eath other or is there any misconfiguration in the repo?

I am using Windows 10 x64, Nodejs 10.16.3 abd Npm 6.9.0. Other libraries are unchanged from the repo.

Important information: the issue can only be reproduced when running node.js commands from a Windows symbolic linked path (e.g. using mklink command).

ike3
  • 1,760
  • 1
  • 17
  • 26

1 Answers1

-1

Seems I found the issue and fixed it. It is surely a bug in Windows 10 affecting filesystem operations... Even using an undocumented feature or a hack.

I had the repo in a symbolic linked directory (https://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/) and completely forgot about it after several years of having this link. A big C/C++ project is located there and link makes no issues with the C/C++ toolchain.

So when I run node commands from a symbolic path the error occurs. When I use the source path (without any links) the error is gone.

I am leaving this here as this may be a very rare case which could be a huge time sink to find the issue if anyone is running node commands from such a linked directory and forced to use Windows by some reason.

ike3
  • 1,760
  • 1
  • 17
  • 26