geelen / react-snapshot

A zero-configuration static pre-renderer for React apps
MIT License
1.66k stars 104 forks source link

UnhandledPromiseRejectionWarning on Crawling #108

Open kbardi opened 6 years ago

kbardi commented 6 years ago

Hi there,

I'm creating a project in react which works ok, but I need to add SEO now, and I think the best option is react-snapshot. I saw some examples and it's really easy to setup.

Anyway, I think there is an error or I didn't understand easy setup. When I run build, and crawling starts, it throws many error, always same error.

Starting crawling http://localhost:62475/ (node:71431) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SyntaxError: Unexpected token < in JSON at position 0 SyntaxError: Unexpected token < in JSON at position 0

I'm using the command npm run build:js so it runs build and react-snapshot.

My package.json is:

{
  "name": "website",
  "version": "0.1.0",
  "scripts": {
    "precommit": "lint-staged",
    "start": "npm-run-all -p watch-css start-js",
    "build": "npm-run-all build-css build-js",
    "lint": "eslint --ext .js src",
    "power-lint": "eslint --ext .js src && npm run lint:style",
    "build-css": "node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/",
    "watch-css": "npm run build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive",
    "start-js": "node scripts/start.js",
    "build-js": "node scripts/build.js && react-snapshot",
    "snap": "react-snapshot",
    "lint:style": "stylelint \"src/**/*.scss\" --syntax scss",
    "fix:eslint": "eslint --fix --ext .js",
    "test": "node scripts/test.js --env=jsdom"
  },
  "dependencies": {
    "airtable": "^0.5.6",
    "autoprefixer": "7.1.6",
    "babel-core": "6.26.0",
    "babel-jest": "20.0.3",
    "babel-loader": "7.1.2",
    "babel-runtime": "6.26.0",
    "case-sensitive-paths-webpack-plugin": "2.1.1",
    "chalk": "1.1.3",
    "country-list": "^1.1.0",
    "css-loader": "0.28.7",
    "dotenv": "4.0.0",
    "dotenv-expand": "4.2.0",
    "extract-text-webpack-plugin": "3.0.2",
    "file-loader": "1.1.5",
    "flat": "^4.1.0",
    "fs-extra": "3.0.1",
    "html-webpack-plugin": "2.29.0",
    "jest": "20.0.4",
    "jquery": "^3.3.1",
    "lodash": "^4.17.10",
    "moment": "^2.22.2",
    "node-sass-chokidar": "^1.3.0",
    "object-assign": "4.1.1",
    "postcss-flexbugs-fixes": "3.2.0",
    "postcss-loader": "2.0.8",
    "promise": "8.0.1",
    "raf": "3.4.0",
    "react": "^16.4.1",
    "react-dev-utils": "^5.0.1",
    "react-dom": "^16.4.1",
    "react-helmet": "^5.2.0",
    "react-intl": "^2.4.0",
    "react-router": "^4.3.1",
    "react-router-dom": "^4.3.1",
    "react-slick": "^0.23.1",
    "react-snapshot": "^1.3.0",
    "resolve": "1.6.0",
    "slick-carousel": "^1.8.1",
    "style-loader": "0.19.0",
    "sw-precache-webpack-plugin": "0.11.4",
    "url-loader": "0.6.2",
    "webpack": "3.8.1",
    "webpack-dev-server": "2.9.4",
    "webpack-manifest-plugin": "1.3.2",
    "whatwg-fetch": "2.0.3"
  },
  "devDependencies": {
    "babel-eslint": "^8.2.5",
    "babel-preset-env": "^1.7.0",
    "babel-preset-react": "^6.24.1",
    "babel-preset-react-app": "^3.1.1",
    "eslint": "^4.19.1",
    "eslint-config-airbnb": "^17.0.0",
    "eslint-loader": "1.9.0",
    "eslint-plugin-babel": "^5.1.0",
    "eslint-plugin-flowtype": "2.39.1",
    "eslint-plugin-import": "^2.13.0",
    "eslint-plugin-jsx-a11y": "^6.0.3",
    "eslint-plugin-markdown": "^1.0.0-beta.6",
    "eslint-plugin-react": "^7.10.0",
    "lint-staged": "^7.2.0",
    "listr": "^0.14.1",
    "npm-run-all": "^4.1.3",
    "sass-loader": "^7.0.3",
    "stylelint": "^9.3.0",
    "stylelint-config-standard": "^18.2.0"
  },
  "lint-staged": {
    "**/*.{js,jsx}": "eslint --ext .js",
    "**/*.less": "stylelint --syntax less"
  },
  "jest": {
    "collectCoverageFrom": [
      "src/**/*.{js,jsx,mjs}"
    ],
    "setupFiles": [
      "<rootDir>/config/polyfills.js"
    ],
    "testMatch": [
      "<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}",
      "<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}"
    ],
    "testEnvironment": "node",
    "testURL": "http://localhost",
    "transform": {
      "^.+\\.(js|jsx|mjs)$": "<rootDir>/node_modules/babel-jest",
      "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
      "^(?!.*\\.(js|jsx|mjs|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
    },
    "transformIgnorePatterns": [
      "[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$"
    ],
    "moduleNameMapper": {
      "^react-native$": "react-native-web"
    },
    "moduleFileExtensions": [
      "web.js",
      "js",
      "json",
      "web.jsx",
      "jsx",
      "node",
      "mjs"
    ]
  },
  "babel": {
    "presets": [
      "react-app"
    ]
  }
}

What am I doing wrong? Thanks in advance!