最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Error: [BABEL] appsrcindex.js: Cannot find module '@babelplugin-proposal-private-property-in-object&#39

programmeradmin3浏览0评论

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

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

Share Improve this question asked Jul 5, 2023 at 1:02 Leonardo RossiLeonardo Rossi 211 gold badge1 silver badge2 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 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./babel/babel/issues/15655

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./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.

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论