ReactJS 随机意外令牌'<'
ReactJS randomly Unexpected token '<'
项目是用 create-react-app 创建的。没有弹出。没有 webpack 配置。默认 "react-scripts": "^3.4.0"
。在 dev
版本上没有错误。但是在生产中,当用户在一页上停留很长时间并单击 link 时,它会显示白页,并且在更新站点(部署新版本)之后。此错误随机出现。控制台输出
Unexpected token '<'
没有其他信息。
有我的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",
}
}
不知道怎么做。但是在启用 sourcemap
之后,这个错误没有显示。
我从 yarn build
:
中删除了这个命令
GENERATE_SOURCEMAP=false
项目是用 create-react-app 创建的。没有弹出。没有 webpack 配置。默认 "react-scripts": "^3.4.0"
。在 dev
版本上没有错误。但是在生产中,当用户在一页上停留很长时间并单击 link 时,它会显示白页,并且在更新站点(部署新版本)之后。此错误随机出现。控制台输出
Unexpected token '<'
没有其他信息。
有我的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",
}
}
不知道怎么做。但是在启用 sourcemap
之后,这个错误没有显示。
我从 yarn build
:
GENERATE_SOURCEMAP=false