2

When i try to deploy my ReactJS on Heroku, i have the error:

PS: I create my ReactJS using CRA (Create-React-App)

ERROR Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: [BABEL] /app/src/index.js: Cannot find module '@babel/plugin-proposal-private-property-in-object

My package.json:

{
  "name": "portfolio-react",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "lucide-react": "^0.257.0",
    "prettier": "^2.8.8",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-icons": "^4.10.1",
    "react-router-dom": "^6.14.1",
    "react-router-hash-link": "^2.4.3",
    "react-scripts": "5.0.1",
    "sass": "^1.63.6",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@babel/core": "^7.22.6",
    "@babel/plugin-proposal-class-properties": "^7.18.6",
    "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
    "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
    "@babel/plugin-transform-runtime": "^7.22.6",
    "@babel/preset-env": "^7.22.6",
    "@babel/preset-react": "^7.22.5",
    "customize-cra": "^1.0.0",
    "node-sass": "^7.0.3",
    "react-app-rewired": "^2.2.1"
  }
}

I try solve the problem creating a many files: config-overrides.js .env .babelrc

3 Answers 3

2

According to the mention on babel github:

Make sure to update @babel/preset-env to 7.22.3 (just replace the version in you devDependencies), then delete the three occurrences of "@babel/plugin-...-private-property-in-object" since they are not needed anymore, and re-run npm install/yarn install/pnpm install (depending on which package manager you are using) to actually download the specified dependencies :)

Try to delete the "@babel/plugin-proposal-private-property-in-object" and re-run install could fix this issue.

Link: https://github.com/babel/babel/issues/15655

1

most of the workaround/fix has been mentioned in the link provided by @YellowD above.

You can also check this link for the same issue: https://github.com/facebook/create-react-app/issues/13189

I just want to note that if it did not work you can try to delete your node_modules and package-lock.json and try to npm install again as it was the ones that worked for me.

0

the package @babel/plugin-proposal-private-property-in-object should be in dependencies instead of devDependencies

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.