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.

Uncaught SyntaxError: Unexpected token <

See original GitHub issue

Bug report

Describe the bug

Getting this error in the web console:

dll_11fbb1faa946535a5071.js?ts=1559223758567:1 Uncaught SyntaxError: Unexpected token <
index.js?ts=1559223758567:1 Uncaught SyntaxError: Unexpected token <
_app.js?ts=1559223758567:1 Uncaught SyntaxError: Unexpected token <
webpack.js?ts=1559223758567:1 Uncaught SyntaxError: Unexpected token <
main.js?ts=1559223758567:1 Uncaught SyntaxError: Unexpected token <

Here is my system, following directly nextjs-news.

// pages/index.js
import React from 'react'

export default class extends React.Component {
  static async getInitialProps({ query, res }) {
    const { color } = query;
    return { color };
  }

  render() {
    const { color, url } = this.props;
    return (
      <div>
        Hello
      </div>
    );
  }
}

// next.config.js
module.exports = {
  target: 'serverless'
}

// now.json
{
  "version": 2,
  "public": false,
  "builds": [
    { "src": "package.json", "use": "@now/next" },
    { "src": "/static/*", "use": "@now/static" }
  ],
  "routes": [
    { "src": "/static/(.*)", "dest": "/static/$1" },
    { "src": "/(.*)", "dest": "/?color=$1" }
  ]
}

// package.json
{
  "name": "next-news",
  "license": "MIT",
  "dependencies": {
    "isomorphic-fetch": "^2.2.1",
    "ms": "^2.1.1",
    "next": "^8.0.0",
    "nprogress": "^0.2.0",
    "react": "^16.7.0",
    "react-dom": "^16.7.0",
    "url-parse": "^1.4.4"
  },
  "scripts": {
    "dev": "now dev",
    "build": "next build",
    "start": "next start",
    "now-build": "next build"
  }
}

Expected behavior

It should load the JS but it’s loading HTML instead.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:24 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
JamieOWilliamscommented, Jul 22, 2019

@timneutkens is there more info on this in the docs somewhere? Can’t seem to find anything about the _next route.

6reactions
javascriptjamescommented, Sep 28, 2020

Why is this closed? There isn’t any real solution for most people having this issue.

@timneutkens I don’t have a .babelrc file and none of these comments pertain to my issue.

Can this be re-opened and looked into further?

Or at least re-opened so others can post their exact issue. I’m not finding any solution in this thread.

Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught SyntaxError: Unexpected token : - Stack Overflow
An "unexpected token" is likely some illegal character code. Such a code is likely not to show up when you print to console....
Read more >
SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >
SyntaxError: Unexpected token in JavaScript | bobbyhadz
The "Uncaught SyntaxError: Unexpected token" occurs for multiple reasons: · The error is also caused if you're making an HTTP request to a...
Read more >
Uncaught SyntaxError: Unexpected token < - JavaScript - iDiallo
All it means is that the interpreter is expecting JavaScript or JSON and you are feeding it HTML/XML. If you don't think you...
Read more >
How to Fix Uncaught SyntaxError: Unexpected token '{'
The JavaScript exceptions " unexpected token " occur when a specific language construct was expected, but something else was provided.
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