Trollbrot Trollbrot - 2 months ago 14
Javascript Question

SyntaxError: Unexpected token '<' - bundle.js not serverd

I deployed a new version of our react website in the morning to our AWS beanstalk development server and something went very wrong.
I got a SyntaxError: Unexpected token '<' from the deployed version. Then I decided to deploy the old version, but that gave the same error. After a lot of trying around I ended up terminating the environment and cloning my production environment to create a new development server, but still the problem is there.

Basically the cloned environment fails, while it works fine on the production server.

The only other strange thing I noticed to far is that when I do

wget http://phoodster-web-dev.eu-west-1.elasticbeanstalk.com/bundle.js
it returns the
index.html
instead of the
bundle.js
file, while our production server does it correctly.

Any idea what is wrong?

Update:
The reason why the bundle.js looks like the index.html is, because the bundle.js was obviously not compiled.
In the nodejs log I might have found the reason:


ERROR in ./~/react-geosuggest/module/input.js Module not found: Error:
Cannot resolve module 'react-addons-shallow-compare' in
/var/app/current/node_modules/react-geosuggest/module @
./~/react-geosuggest/module/input.js 15:33-72

ERROR in ./~/react-geosuggest/module/suggest-list.js Module not found:
Error: Cannot resolve module 'react-addons-shallow-compare' in
/var/app/current/node_modules/react-geosuggest/module @
./~/react-geosuggest/module/suggest-list.js 13:33-72

ERROR in ./~/react-geosuggest/module/suggest-item.js Module not found:
Error: Cannot resolve module 'react-addons-shallow-compare' in
/var/app/current/node_modules/react-geosuggest/module @
./~/react-geosuggest/module/suggest-item.js 13:33-72


Still very strange, why it fails only on the new clone and not the main server.

Answer

You are missing the relevant javascript code in bundle.js It looks like an index.html without content this could be due to overwriting the file on accident or that you have some compile errors in your tests

Edit:

you need to install the node modules this way ( in the console )

  npm i react-addons-shallow-compare

So it won't fail again it's just missing the module