2

Project was created with create-react-app. Did not eject. There are no webpack configs. Default "react-scripts": "^3.4.0". On dev version there is no error. But on production when user stays long on one page and clicks the link it shows white page, and after updating the site(deploying new version). This error randomly appears. Output on console

Unexpected token '<'

and no other information.

There is my package.json

{
  "name": "project-name",
  "version": "2.0.0",
  "description": "description",
  "private": true,
  "dependencies": {
    "@bugsnag/js": "^6.5.0",
    "@bugsnag/plugin-react": "^6.5.0",
    "@glidejs/glide": "^3.4.1",
    "@material-ui/core": "^4.4.1",
    "@sentry/browser": "^5.11.2",
    "@sentry/cli": "^1.49.0",
    "@types/jest": "^25.1.3",
    "@types/node": "^13.7.4",
    "@types/rc-switch": "^1.9.0",
    "@types/react": "^16.9.22",
    "@types/react-dom": "^16.9.5",
    "axios": "^0.19.0",
    "chart.js": "^2.9.1",
    "classnames": "2.2.6",
    "debounce-promise": "^3.1.2",
    "formik": "^1.5.8",
    "jquery": "^3.4.1",
    "logrocket": "^1.0.6",
    "logrocket-react": "^4.0.1",
    "moment": "2.24.0",
    "moment-timezone": "^0.5.27",
    "orgchart": "^2.1.5",
    "prop-types": "^15.7.2",
    "purgecss": "^1.4.0",
    "rc-switch": "^1.9.0",
    "react": "^16.9.0",
    "react-autosuggest": "^9.4.3",
    "react-chartjs-2": "^2.7.6",
    "react-circular-progressbar": "^2.0.2",
    "react-contextmenu": "^2.11.0",
    "react-data-export": "^0.6.0",
    "react-datepicker": "^2.9.6",
    "react-dom": "^16.9.0",
    "react-dropzone-component": "^3.2.0",
    "react-intl": "2.4.0",
    "react-perfect-scrollbar": "^1.5.3",
    "react-redux": "7.1.1",
    "react-router-dom": "^5.0.1",
    "react-scripts": "^3.4.0",
    "react-select": "^3.0.4",
    "react-select-async-paginate": "^0.3.10",
    "react-table": "latest",
    "react-transition-group": "^4.3.0",
    "reactstrap": "^8.0.1",
    "redux": "^4.0.4",
    "redux-saga": "^1.0.5",
    "styled-components": "^5.0.0",
    "tailwindcss": "^1.1.2",
    "typescript": "^3.8.2",
    "xlsx": "^0.15.5",
    "yup": "^0.27.0"
  },
  "scripts": {
    "start": "yarn run tailwind && react-scripts start",
    "build": "yarn run tailwind && node ./purge-tailwindcss.js && cross-env react-scripts build",
    "tailwind": "./node_modules/.bin/tailwind build ./src/assets/css/vendor/tailwind.base.css -c ./tailwind.js -o ./src/assets/css/vendor/tailwind.css",
    "test": "react-scripts test --env=node",
    "crt": "bash create-component.sh",
    "eject": "react-scripts eject",
    "lint": "eslint src/**/*.js"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {
    "babel-plugin-import": "^1.13.0",
    "cross-env": "^5.2.0",
    "eslint": "^6.8.0",
    "eslint-config-airbnb": "^18.0.1",
    "eslint-plugin-import": "^2.20.0",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-react": "^7.18.0",
    "eslint-plugin-react-hooks": "^1.7.0",
    "node-sass": "^4.12.0",
  }
}
6
  • Reactjs: Unexpected token '<' Error did you refer this link, if its helpful let me know Commented Feb 25, 2020 at 5:34
  • @pavankumar yes I checked. And I tried to change like type = "text/babel" but it's not solution. And other answers includes webpack improvement. But I use react-script for build Commented Feb 25, 2020 at 5:45
  • did you try type="text/jsx" as your script type? Commented Feb 25, 2020 at 5:47
  • @pavankumar I tried it too. create-react-app doesn't add any types on build for scripts. Commented Feb 25, 2020 at 6:00
  • Did you check compatibility between node version and react-scripts on production Commented Feb 27, 2020 at 6:22

1 Answer 1

1

Don't know how. But after enabling sourcemap this error doesn't shown. I removed this command from yarn build:

GENERATE_SOURCEMAP=false
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.