我有一个全新安装yarn(通过npm install yarn -g)并试图安装一些包
yarn add vue-loader babel-loader style-loader css-loader file-loader webpack
Run Code Online (Sandbox Code Playgroud)
我在安装过程中收到了一些警告,例如
warning "vue-loader@13.3.0" has unmet peer dependency "vue-template-compiler@^2.0.0".
Run Code Online (Sandbox Code Playgroud)
这究竟是什么意思,具体而言:为什么不自行yarn安装这些依赖项?(如果需要的话)
关于同一主题的姐妹问题(关于npm)产生一些答案,其表明i)更新npmii)删除node_modules因为存在npm关于处理依赖性的错误.
这种警告的状态是什么yarn?这真的是一个警告(=我可以丢弃的东西)?我不能丢弃它们(webpack构建失败)并且必须手动安装它们.同时,安装了很多依赖项,所以我不明白为什么会错过一些(虽然它们可以手动安装)
小智 28
这里有一些关于依赖类型的有用的阅读,这里是关于对等依赖的信息,但总结一下:
依赖关系:项目需要运行的库/包.
对等依赖:用于指示项目将挂钩的库/包.
该软件包vue-loader具有对等依赖性vue-template-compiler- vue-loader充当插件vue-template-compiler
直接依赖关系自动安装到npm @ 3(纱线已经跟进).由于经常混淆行为而停止了这一点.例如,安装另一个具有冲突要求的插件会导致错误.
我们还将在npm @ 3中更改peerDependencies的行为.我们不会再自动下载对等依赖项了.相反,如果尚未安装对等依赖项,我们将警告您.这需要您自己手动解决peerDependency冲突,但从长远来看,这将使您不太可能最终陷入与包的依赖关系的棘手问题.[2015年2月13日]
lca*_*pra 14
运行yarn install --check-files或 就yarn install可以解决问题并安装缺少的依赖项。
明确添加到您的package.json也可能是一种选择。
参考https://github.com/yarnpkg/yarn/issues/4594#issuecomment-763475899
正如其他人所提到的,对等依赖项是库所需的其他包,必须将其添加到父包的依赖项中,而不是直接添加到库中。
要解决此警告,您应该yarn add <package>针对每个<package>被投诉的问题运行。下面是一个例子。
原始输出来自yarn install:
$ yarn install
yarn install v1.22.15
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@2.3.2: The platform "linux" is incompatible with this module.
info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > react-markdown@8.0.3" has unmet peer dependency "@types/react@>=16".
warning "react-scripts > eslint-config-react-app > eslint-plugin-flowtype@8.0.3" has unmet peer dependency "@babel/plugin-syntax-flow@^7.14.5".
warning "react-scripts > eslint-config-react-app > eslint-plugin-flowtype@8.0.3" has unmet peer dependency "@babel/plugin-transform-react-jsx@^7.14.9".
warning "react-scripts > react-dev-utils > fork-ts-checker-webpack-plugin@6.5.2" has unmet peer dependency "typescript@>= 2.7".
warning "react-scripts > eslint-config-react-app > @typescript-eslint/eslint-plugin > tsutils@3.21.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
[4/4] Building fresh packages...
Done in 8.91s.
Run Code Online (Sandbox Code Playgroud)
解决警告的命令:
yarn add '@types/react@>=16' '@babel/plugin-syntax-flow@^7.14.5' '@babel/plugin-transform-react-jsx@^7.14.9' 'typescript@>= 2.7' '@babel/core@^7.0.0-0' 'typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta'
Run Code Online (Sandbox Code Playgroud)
您现在可以运行rm -rf node_modules/ && yarn来测试输出是否干净:
$ yarn
yarn install v1.22.15
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@2.3.2: The platform "linux" is incompatible with this module.
info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 9.05s.
Run Code Online (Sandbox Code Playgroud)
请注意,您可能会注意到,如果新添加的依赖项具有任何对等依赖项,则必须重复此过程。
| 归档时间: |
|
| 查看次数: |
15581 次 |
| 最近记录: |