I have a React app with webpack that is building and running fine in local. I am currently testing with a stripped down version that just renders a header text.
However, when I deploy through Jenkins to an S3 bucket, I am getting Uncaught SyntaxError: Invalid or unexpected token (at bundle.js:2:55245) in the console. No build errors in Jenkins that stand out to me, other than warnings that I also get when I build locally. The error also doesn't specify a spcific token
Any insights or advice on avenues to pursue?
Related
I'm facing issue while running my project in react-native. I changed the app name by using package react-native-rename but since then I'm getting that errors:
anyone know how to fix that?
I have used the React-Hot-Toast in my React application bootstrapped by Vite.
The website is running smoothly in the developing mode.
However, I encounter an error when I am building the site by npm run build.
[vite]: Rollup failed to resolve import "react-hot-toast" from "src/App.jsx".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
I followed its suggestion to put the rollupOptions in the vite.config.js.
Though it was successfully built, the website in the preview mode crashed immediately.
And I have received the following error in the browser's console.
Uncaught TypeError: Failed to resolve module specifier "react-hot-toast". Relative references must start with either "/", "./", or "../".
I have no idea what I should be done or if I had made something wrong.
Since the website is widely applying react-hot-toast, I would love to see if the problem can be fixed without replacing the library.
Thanks in advance.
My website (wsb-tracker.com) is inexplicably getting this error when deployed (with Netlify), but not when run locally:
Whenever I deploy my heroku app with the create-react-app buildpack, the first time I try to access my domain, the page loaded is white and there is an error in the developer console saying
Uncaught SyntaxError: Unexpected token <
in the file main.6396d38a.js:1 which is generated by the react build. However, when I refresh the page, the website works perfectly fine. Is there a reason this could be happening? I tried to replicate the error on my localhost using npm run build, and serve -s build but my website works perfectly fine there. Why would this only show up once after every react deploy to heroku?
My package.json has a homepage associated with the domain name of my website (not .herokuapp.com)
"homepage": "https://www.example.com/"
Inside your package.json make sure your homepage URL is correct:
"homepage": "https://app.herokuapp.com/"
Update
Further investigation shows this was a caching issue. Clearing cookies, website content, and DNS fixed the issue.
I have a working yarn react project on a local machine.
yarn start
Works, yields a website that renders on the local host.
I have a server that was running the same project. However, I stopped the running website, and restarted with the following commands:
yarn install
yarn run build
yarn run prod
And I get the following error when accessing the website through chrome (on the production server):
Ucaught SyntaxError: Unexpected token <
What I am trying to do is diagnose where the problems could be arising. To summarize:
1) the project runs on the local machine (mac osx) with yarn start
2) I place the project on the linux box, install, build and run and everything seems to be sending to chrome; however, chrome yields this error
I am not sure where the problem could be. Localizing it to a set of possible problems would, I think, make it easy to solve (or ask better questions).
That error typically happens when you are getting a HTML page for a <script> tag src's address.
Open the URLs of the scripts each on a different tab (or check the network tab of the developer tools), those URLs are probably returning a 404 (or some other error code) and a HTML error page.
So your code tries to parse those HTML error pages as JavaScript code, thus yielding that error.
It gets Uncaught SyntaxError: Unexpected token < because it tries to parse the HTML content (e.g. <html> ...) as JavaScript code.
For a demo, run the snippet below and see the error at the console.
<script type=text/javascript src=https://stackoverflow.com></script>
Check the console: "Uncaught SyntaxError: Unexpected token <"