'Why is git commit running Next build command despite the correct package.json script?
In my Nextjs app, when I run git add . then git commit -m '(add) some message', it runs Next build before it can commit.
This did not happen before, and the package.json's build script is correct.
Why could this be happening and how can I fix this?
package.json
{
"name": "sbs",
"author": "Small Batch Standard",
"license": "ISC",
"version": "1.0.0",
"private": true,
"_moduleAliases": {
"src": "./src"
},
"scripts": {
"dev": "next dev",
"start": "next start",
"build": "next build",
"export": "cross-env GENERATE_SOURCEMAP=false next build && next export",
"prettier": "prettier --write '**/*.{js,css,html}'",
"lint": "eslint --quiet --fix",
"clear-all": "rimraf ./.cache ./.next ./node_modules",
"prepare": "husky install"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
"eslint --fix",
"git add"
]
},
"dependencies": {
"@auth0/auth0-react": "^1.5.0",
"@auth0/auth0-spa-js": "^1.13.6",
"@devexpress/dx-react-grid-material-ui": "^3.0.2",
"@emotion/cache": "^11.1.3",
"@emotion/react": "^11.1.5",
"@emotion/styled": "^11.1.5",
"@fullcalendar/core": "^5.5.0",
"@fullcalendar/daygrid": "^5.5.0",
"@fullcalendar/interaction": "^5.5.0",
"@fullcalendar/list": "^5.5.0",
"@fullcalendar/react": "^5.5.0",
"@fullcalendar/timegrid": "^5.5.0",
"@fullcalendar/timeline": "^5.5.0",
"@material-ui/core": "^5.0.0-alpha.27",
"@material-ui/icons": "^5.0.0-alpha.27",
"@material-ui/lab": "^5.0.0-alpha.27",
"@material-ui/system": "^5.0.0-alpha.27",
"@material-ui/utils": "^5.0.0-alpha.27",
"@mui/icons-material": "^5.6.1",
"@mui/material": "^5.6.2",
"@nivo/core": "^0.71.0",
"@nivo/line": "^0.71.0",
"@nivo/tooltip": "^0.71.0",
"@react-pdf/renderer": "^1.6.13",
"@reduxjs/toolkit": "^1.5.0",
"@testing-library/jest-dom": "^5.11.9",
"apexcharts": "^3.23.1",
"axios": "^0.21.1",
"axios-mock-adapter": "^1.19.0",
"chroma-js": "^2.1.2",
"classnames": "^2.3.1",
"clsx": "^1.1.1",
"date-fns": "^2.16.1",
"depcheck": "^1.4.0",
"draft-js": "^0.11.7",
"formik": "^2.2.6",
"gray-matter": "^4.0.2",
"i18next": "^19.8.7",
"js-cookie": "^2.2.1",
"lodash": "^4.17.20",
"moment": "^2.29.1",
"next": "^10.0.1",
"next-images": "^1.6.2",
"normalizr": "^3.6.1",
"notistack": "^1.0.9",
"nprogress": "^0.2.0",
"numeral": "^2.0.6",
"prop-types": "^15.7.2",
"react": "^17.0.1",
"react-apexcharts": "^1.3.7",
"react-beautiful-dnd": "^13.0.0",
"react-dom": "^17.0.1",
"react-draft-wysiwyg": "^1.14.5",
"react-dropzone": "^11.2.4",
"react-helmet-async": "^1.0.7",
"react-hook-form": "^7.9.0",
"react-i18next": "^11.8.5",
"react-icons": "^4.3.1",
"react-infinite-scroll-component": "^6.1.0",
"react-markdown": "^5.0.3",
"react-modal-image": "^2.5.0",
"react-number-format": "^4.6.3",
"react-perfect-scrollbar": "^1.5.8",
"react-quill": "^1.3.5",
"react-redux": "^7.2.2",
"react-scripts": "^4.0.1",
"react-syntax-highlighter": "^15.4.3",
"react-virtualized": "^9.22.3",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0",
"stylis": "^4.0.6",
"stylis-plugin-rtl": "^2.0.1",
"typescript": "^4.1.3",
"web-vitals": "^1.1.0",
"yup": "^0.32.8",
"zustand": "^3.4.2"
},
"devDependencies": {
"@types/chroma-js": "^2.1.3",
"@types/history": "^4.7.8",
"@types/jest": "^26.0.20",
"@types/lodash": "^4.14.167",
"@types/nprogress": "^0.2.0",
"@types/react": "^17.0.0",
"@types/react-beautiful-dnd": "^13.0.0",
"@types/react-dom": "^17.0.0",
"@types/react-draft-wysiwyg": "^1.13.1",
"@types/react-redux": "^7.1.15",
"@types/uuid": "^8.3.4",
"@types/yup": "^0.29.11",
"@typescript-eslint/eslint-plugin": "^4.4.1",
"@typescript-eslint/parser": "^4.22.0",
"babel-plugin-styled-components": "^1.12.0",
"cross-env": "^7.0.2",
"eslint": "^7.25.0",
"eslint-config-airbnb-typescript": "^12.3.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.2.0",
"husky": "^7.0.0",
"jest": "^26.6.3",
"lint-staged": "^10.5.4",
"prettier": "^2.2.1",
"prettier-plugin-organize-imports": "^1.1.1"
}
}
git ci is an alias for git commit, and it has been working before so that is not the culprit
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

