Skip to content

Uncaught SyntaxError: Unexpected token 'less than symbol'

Edward edited this page Jan 14, 2017 · 1 revision

This can be caused by a number of things. The main way to resolve it (I found) was to ensure that the index.html and js files are being located/properly referenced. For example, when deploying to Heroku, I ran into this issue quite a lot, and it was caused by incorrectly importing static assets. To fix this, static files are set up using the following lines of code in server.js:

app.use(express.static(__dirname));
app.use(express.static(path.join(__dirname, '../../client/build')));

and index.html is served up by this snippet of code from server.js:

app.get('/*', function(req, res) {
  res.sendFile(path.join(__dirname, '../../client/build/index.html'));
});

Clone this wiki locally