Search code examples
reactjsnpmreact-static

Error: "Module parse failed: Unexpected token" when building react-static app template


I got this error when creating a fresh app from react-static blank template, after clean up the windows environment and reinstall nodejs and react-static, following this procedure.

ERROR in /.../react-static-test/react-static-test/dist/react-static-templates.js 1:1051 Module parse failed: Unexpected token (1:1051) You may need an appropriate loader to handle this file type.

The procedure is good, help me in pass more than once, but for some reason seams to be some instability in the package tree for react-static.


Solution

  • Here the solution, taken from react-static support, for next folk don't have to dig into web for it:

    1. rm -rf node_modules
    2. rm -rf package-lock.json
    3. npm install
    4. npm install [email protected] -D
    5. npm run serve

    According to react-static support post, it is a npm bug.