Search code examples
reactjsdeploymentgithub-pages

Not able to host on github-pages due to error with React Router


Here's the link to my portfolio website that I'm trying to deploy on github-pages: https://github.com/AbhishekM2001/AbhishekM2001.github.io

The site is working properly when deployed locally but when I try to deploy on github pages I get the error: 'Syntax Error,Unexpected <' on the line where React Router is implemented in index.js file. I've also used Hashrouter instead of Router but to no avail.

Any help would be appreciated.


Solution

  • For anyone else stuck on the issue, I had bundled all my files using parcel bundler so the index.html in dist folder was being served instead of the index.html in root folder. Using gh-pages to set dist as root folder worked for me.

    Refer the commands in https://stackoverflow.com/a/42501045/11566161 Courtesy: Shri Hari L in comments.