stereobooster / react-snap

👻 Zero-configuration framework-agnostic static prerendering for SPAs
MIT License
5.05k stars 394 forks source link

Unknown script: "postbuild" (CRA and React Snap) #505

Closed chrisfinazzo closed 3 years ago

chrisfinazzo commented 3 years ago

Bug Report

Current Behavior I want to upgrade to the latest version of create-react-app and also move from React Snapshot to using React Snap. However, after making changes to the package.json file and running the migration (e.g, npm install --save --save-exact react-scripts@4.0.0), an error occurs which says the postbuild script is unknown.

I suspect this is a configuration error, but my package is valid JSON (current version is included below)

Thoughts on what I might have missed here?

Reproducible demo

{
    "name": "reverse-job-posting",
    "version": "0.1.0",
    "keywords": [
        "microsite",
        "reactjs"
    ],
    "homepage": "https://hirechrisfinazzo.com",
    "repository": {
        "type": "git",
        "url": "https://github.com/chrisfinazzo/reverse-job-posting.git"
    },
    "author": {
        "name": "Chris Finazzo",
        "url": "https://chrisfinazzo.com/"
    },
    "private": true,
    "dependencies": {
        "@fortawesome/fontawesome-svg-core": "^1.2.32",
        "@fortawesome/free-brands-svg-icons": "^5.15.1",
        "@fortawesome/react-fontawesome": "^0.1.11",
        "@testing-library/jest-dom": "^4.2.4",
        "@testing-library/react": "^9.3.2",
        "@testing-library/user-event": "^7.1.2",
        "react": "^16.13.1",
        "react-dom": "^16.13.1",
        "react-helmet": "^6.1.0",
        "react-router-dom": "^5.2.0",
        "react-scripts": "4.0.0",
        "react-snap": "^1.13.1",
        "styled-components": "^5.2.0"
    },
    "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build && react-scripts postbuild",
        "postbuild": "react-snap",
        "test": "react-scripts test",
        "eject": "react-scripts eject",
        "sass": "sass --watch --style=compressed src/sass/app.scss:public/css/app.css"
    },
    "browserslist": {
        "production": [
            ">0.2%",
            "not dead",
            "not op_mini all"
        ],
        "development": [
            "last 1 chrome version",
            "last 1 firefox version",
            "last 1 safari version"
        ]
    }
}

Expected behavior/code

npm run build should create a production build of the site.

InSuperposition commented 3 years ago

postbuild will run after build, its part of npm. https://docs.npmjs.com/cli/v6/using-npm/scripts#pre--post-scripts

Remove && react-scripts postbuild