Uncaught SyntaxError: Unexpected token <
See original GitHub issueBug 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:
- Created 4 years ago
- Reactions:3
- Comments:24 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@timneutkens is there more info on this in the docs somewhere? Can’t seem to find anything about the
_nextroute.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