0

I have created a website using ReactJS and is running perfect on my local machine. But when I run npm run build this is the error I got:

> react-snap

�  pageerror at /personal-site/: SyntaxError: Unexpected token '<'

✅  crawled 1 out of 1 (/personal-site/)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! personal-site@2.1.0 postbuild: `react-snap`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the personal-site@2.1.0 postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\[MYUSERNAMEHERE]\AppData\Roaming\npm-cache\_logs\2020-08-24T04_04_29_334Z-debug.log

I am planning to deploy this to github pages. In my package.json, I have the following line as homepage:

"name": "personal-site",
"version": "2.1.0",
"homepage": "https://[MYUSERNAME].github.io/personal-site/",

Note that personal-site is the name of my project and repository both. I also have a .env file that looks like the following:

NODE_ENV=production

PORT=7999
BASE_PATH=/personal-site/

What is the reason for this error? Also, How can I overcome this error?

The following is the debug log. [Trimmed]

...
24 verbose node v12.18.1
25 verbose npm  v6.14.5
26 error code ELIFECYCLE
27 error errno 1
28 error personal-site@2.1.0 postbuild: `react-snap`
28 error Exit status 1
29 error Failed at the personal-site@2.1.0 postbuild script.
29 error This is probably not a problem with npm. There is likely additional logging output above.
30 verbose exit [ 1, true ]
Chris
  • 1
  • 1

1 Answers1

-1

Hi check your code you have some extra '<' or you are missing some '<' closing tag see your error code its clearly says that

pageerror at /personal-site/: SyntaxError: Unexpected token '<'

  • Thank you for your response, but I don't think this is the actual error. Anyway, I have checked the code, there is no such extra or missing '<'. Also, If this was the error, The same error should be present when I run on `localhost`. Fortunately, I don't get this error when I run this on localhost. – Chris Aug 24 '20 at 04:35
  • You can read this i m telling you this because i has the same error before this and i have checked that and really its was there so that why i am telling you see ts clearly says this Unexpected token '<' –  Aug 24 '20 at 04:42
  • If you still have that issue you can use this it will help you npm "run build -prod" then after this extend the javascript memory node --max_old_space_size=4096 node_modules/@react/cli/bin/ng build --prod hope this will work –  Aug 24 '20 at 04:46