question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deployed site: Uncaught SyntaxError: Unexpected token <

See original GitHub issue

After building the site with:

ng build --prod --base-href "https;//<username>.github.io/<reponame>/

I can run the site with no issues on a local server.

However, after publishing via ngh, the online site just gives the following error 4 times:

SyntaxError: Unexpected token < (index):1

No other errors or information is given, so I have no idea what to do.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:18 (5 by maintainers)

github_iconTop GitHub Comments

59reactions
vaibhav269commented, Jul 13, 2018

I was facing the same issue .This is due the creation of project directory inside the dist folder which is not being pointed by index.html. Fixed it by changing the base tag from <base href="/"> to <base href="/project-app/"> inside index.html file.

6reactions
TyrantWavecommented, Sep 17, 2017

From my understanding, github pages require a _config.yml file, so the project structure I uploaded had to look like the following:

| assets/
+   | files
| _config.yml
| index.html
| inline/main/polyfills/styles/vendor.js

Until I had _config.yml, the site would constantly fail with the error in the original post. It worked as soon as the file was present.

Inside _config.yml I specified the base URL: baseurl: /ng2-parallaxscroll

Here’s the full project, check the origin/docs branch for the website source, and the gh-pages for the built output: https://github.com/TyrantWave/ng2-parallaxscroll

To add the _config.yml to the output, I added it to the angular.cli.json assets folder:

  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico",
        "_config.yml"
      ],
  ...
  ]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught SyntaxError: Unexpected token '<' - Stack Overflow
I uploaded my react project to Netlify but when I clicked on the link nothing came out and there was the following error...
Read more >
"Uncaught SyntaxError: Unexpected token <" after firebase ...
Ths issue is caused when a new version of firebase hosting is deployed, it might have wiped out all the resources serving from...
Read more >
uncaught syntaxerror: unexpected token '<' - Build debugging
Hello trying to deploy a mern app. I built the front-end following the create-react-app docs, placed the build in the backend and proceeded ......
Read more >
Error "Uncaught SyntaxError: Invalid or Unexpected Token ...
Coding example for the question Error "Uncaught SyntaxError: Invalid or Unexpected Token", When Deploying Site on Netlify-Reactjs.
Read more >
Unexpected token <' has been thrown (node.js, express) - Quora
How do you deploy to Heroku when "Uncaught SyntaxError: Unexpected token <" has ... part of the page, rather than getting to a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found