heroku requests a library that is already installed

Viewed 24

I have 1 problem with heroku autobuild

Stack heroku-20

{
  "name": "app",
  "version": "1.0.0",
  "scripts": {
    "dev": "cross-env next",
    "build": "next build",
    "start": "cross-env node server.js -p $PORT"
  },
  "engines": {
    "node": "16.14.0",
    "npm": "8.5.3"
  },
  "dependencies": {
    "@date-io/date-fns": "^2.14.0",
    "@date-io/moment": "^2.14.0",
    "@emotion/cache": "^11.4.0",
    "@emotion/core": "^11.0.0",
    "@emotion/react": "^11.4.1",
    "@emotion/server": "^11.4.0",
    "@emotion/styled": "^11.3.0",
    "@mui/icons-material": "^5.6.2",
    "@mui/lab": "^5.0.0-alpha.80",
    "@mui/material": "^5.6.4",
    "@mui/x-date-pickers": "^5.0.0-beta.2",
    "@unly/universal-language-detector": "^2.0.3",
    "@zeit/next-css": "^1.0.1",
    "axios": "^0.21.1",
    "babel-plugin-styled-components": "^1.12.0",
    "cookies": "^0.8.0",
    "create-emotion-server": "^11.0.0",
    "date-fns": "^2.28.0",
    "dotenv": "^8.6.0",
    "express": "^4.17.1",
    "formik": "^2.2.6",
    "i18next": "^19.9.2",
    "i18next-browser-languagedetector": "^5.0.1",
    "i18next-localstorage-cache": "^1.1.1",
    "js-cookie": "^2.2.1",
    "jwt-decode": "^2.2.0",
    "markdown": "^0.5.0",
    "moment": "^2.29.3",
    "next": "^10.1.3",
    "next-cookies": "^1.1.3",
    "next-redux-wrapper": "^4.0.1",
    "prop-types": "^15.7.2",
    "react": "^17.0.2",
    "react-copy-to-clipboard": "^5.0.4",
    "react-dom": "^17.0.2",
    "react-i18next": "^11.10.0",
    "react-redux": "^7.2.4",
    "react-window": "^1.8.7",
    "redux": "^4.1.0",
    "redux-devtools-extension": "^2.13.9",
    "redux-thunk": "^2.3.0",
    "styled-components": "^4.4.1",
    "@types/react": "^17.0.0"
  },
  "devDependencies": {
    "@babel/plugin-proposal-class-properties": "^7.13.0",
    "@babel/plugin-proposal-export-default-from": "^7.12.13",
    "@svgr/webpack": "^5.5.0",
    "@types/node": "^12.20.12",
    "@types/react": "^17.0.0",
    "@types/react-dom": "^16.9.12",
    "@types/react-redux": "^7.1.16",
    "@types/styled-components": "^5.1.9",
    "@typescript-eslint/eslint-plugin": "^4.26.0",
    "@typescript-eslint/parser": "^4.26.0",
    "babel-loader": "8.0.5",
    "cross-env": "^7.0.3",
    "eslint": "^7.25.0",
    "eslint-config-airbnb": "^18.2.1",
    "eslint-plugin-import": "^2.23.4",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-react": "^7.24.0",
    "eslint-plugin-react-hooks": "^4.2.0",
    "file-loader": "^6.2.0",
    "html-webpack-plugin": "^5.3.1",
    "husky": "^6.0.0",
    "nodemon": "^2.0.7",
    "prettier": "^2.2.1",
    "ts-node": "^8.10.2",
    "tslint": "^6.1.3",
    "typescript": "^4.3.2",
    "url-loader": "^4.1.0",
    "webpack": "^5.38.1",
    "webpack-cli": "^4.7.0",
    "webpack-dev-middleware": "^4.1.0",
    "webpack-dev-server": "^3.11.2"
  }
}

The stack is next.js. Locally, I can build the project. But on heroku it asks for a library @types/react

-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/nodejs
-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 16.x...
       Downloading and installing node 16.17.0...
       Using default npm version: 8.15.0
       
-----> Restoring cache
       Cached directories were not restored due to a change in version of node, npm, yarn or stack
       Module installation may take longer for this build
       
-----> Installing dependencies
       Installing node modules (package.json)
       
       added 1489 packages, and audited 1490 packages in 1m
       
       160 packages are looking for funding
         run `npm fund` for details
       
       26 vulnerabilities (1 low, 9 moderate, 13 high, 3 critical)
       
       To address issues that do not require attention, run:
         npm audit fix
       
       To address all issues possible (including breaking changes), run:
         npm audit fix --force
       
       Some issues need review, and may require choosing
       a different dependency.
       
       Run `npm audit` for details.
       
-----> Build
       Running build
       
       > app@1.0.0 build
       > next build
       
       info  - Using webpack 4. Reason: custom webpack configuration in next.config.js https://nextjs.org/docs/messages/webpack5
       warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
       Attention: Next.js now collects completely anonymous telemetry regarding usage.
       This information is used to shape Next.js' roadmap and prioritize features.
       You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
       https://nextjs.org/telemetry
       
       info  - Checking validity of types...
It looks like you're trying to use TypeScript but do not have the required package(s) installed.
Please install @types/react by running:
    npm install --save-dev @types/react
If you are not trying to use TypeScript, please remove the tsconfig.json file from your package root (and any TypeScript files in your pages directory).
-----> Build failed
       
       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys
       
       Some possible problems:
       
       - Node version not specified in package.json
         https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
       
       Love,
       Heroku
       
 !     Push rejected, failed to compile Node.js app.
 !     Push failed

The same code worked and loaded, builded successfully on August 12. But today (September 13) it stopped building on heroku

I've tried rebooting, changing version, etc. But it didn't help.

I tried to upload the old code to heroku, which had already been successfully uploaded earlier, but the error was still the same

I changed node.js and npm version locally and in package for heroku and that didn't help either

1 Answers

Problem solved. Updated the following packages

"@types/node": "18.7.18",
"@types/react": "18.0.1",
"@types/react-dom": "18.0.6",
"eslint-config-next": "12.3.0",
"typescript": "4.8.3"

And added "@types/react" to devDependencies and dependencies

Related