使用create-react-app时如何更新现有依赖关系?

问题描述 投票:2回答:2

我正在为项目使用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
2个回答
0
投票

package.json中的内容将具有优先权,因此,如果您升级eslint版本,则react-scripts应该始终采用最新版本。

虽然有一个小漏洞。 如果您过多地依赖于依赖项,那么您可能会通过react-scripts收到有关版本不匹配的警告。 为避免这种情况,您可以创建.env文件,并可以指定以下内容。

SKIP_PREFLIGHT_CHECK=true

0
投票

我刚刚解决了这个问题,错误提示: 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)

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

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