npm start 和安装软件包的问题:有关 babel-preset-react-app 依赖项的警告和审核修复冻结了 VSCode

问题描述 投票:0回答:1

每当我跑步时

npm start
我都会遇到这条消息:

One of your dependencies, babel-preset-react-app, is importing the
"@babel/plugin-proposal-private-property-in-object" package without
declaring it in its dependencies. This is currently working because
"@babel/plugin-proposal-private-property-in-object" is already in your
node_modules folder for unrelated reasons, but it may break at any time.

babel-preset-react-app is part of the create-react-app project, which
is not maintianed anymore. It is thus unlikely that this bug will
ever be fixed. Add "@babel/plugin-proposal-private-property-in-object" to
your devDependencies to work around this error. This will make this message
go away.

但是,我可以运行

npm start
并在本地浏览器上查看。 问题不仅是这个黄色警告消息很烦人,而且无论我尝试通过终端安装什么, 我只是收到很多错误和警告。 我什至无法使用命令安装 bootstrap 或 fontawesome。

它建议我运行一些修复命令,但 100% 运行

audit fix
- 有点代码只会让情况变得更糟。 要么出现很多错误并出现红屏,要么我的 VScode 在未完成修复内容的情况下被冻结。

我不得不重新启动我的笔记本电脑。 :(

这是我的

package.json
,以防万一:

{
  "name": "devsimple",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.17.0",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "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"
    ]
  }
}

有人知道该怎么办吗?谢谢!!

reactjs npm dependencies create-react-app hadoop-yarn
1个回答
0
投票

我也有类似的问题。

npm install --save-dev @babel/plugin-proposal-private-property-in-object --legacy-peer-deps

为我工作

解决方法请参考以下链接 babel-preset-react-app,正在导入“@babel/plugin-proposal-private-property-in-object”包,而不在其依赖项中声明它

© www.soinside.com 2019 - 2024. All rights reserved.