首页 > 解决方案 > 使用 create-react-app 时如何更新预先存在的依赖项?

问题描述

我正在使用create-react-app一个项目。我安装了各种 eslint 插件等,但是,我们都知道 create-react-app 已经带有某些未在package.json.

我想要eslint目前是 5.3.0 的最新版本。Create-react-app 附带 5.16.0。没有弹出,我如何在不破坏一切的情况下将此依赖项带到最新版本?

我收到以下错误:

The react-scripts package provided by Create React App requires a dependency:

  "eslint": "^5.16.0"

Don't try to install it manually: your package manager does it automatically.
However, a different version of eslint was detected higher up in the tree:

:\node_modules\eslint (version: 5.3.0)

标签: reactjs

解决方案


我刚刚解决了这个问题,错误说: The react-scripts package provided by Create React App requires a dependency: "eslint": "5.16.0"

但也说你在 package.json 有另一个版本, \node_modules\eslint (version: 5.3.0)在我的情况下是 6.1.0

所以我的解决方案是:我搜索了名为 eslint 的依赖项,并更新了类似于"eslint": "^5.16.0"在 package.json 中预期的 Create React App 的版本然后运行npm install,现在你可以运行 npm start ... 如果你也遇到了slint-plugin-import更新版本的问题。


推荐阅读