简体   繁体   English

npm peerDependency-无法安装软件包

[英]npm peerDependency - can't install package

I'm new to npm world, so maybe it's easy. 我是npm world的新手,所以也许很简单。 The problem is the following: 问题如下:

I have a project with installed react v.15.2.0 , and I need to install a package, eg react typist - https://github.com/jstejada/react-typist . 我有一个安装了react v.15.2.0的项目,我需要安装一个软件包,例如react typist - https://github.com/jstejada/react-typist When I do it, I gen an error: (npm v2.*) 当我这样做时,我产生了一个错误:(npm v2。*)

npm ERR! npm ERR! peerinvalid The package react@15.2.1 does not satisfy its siblings' peerDependencies requirements! peerinvalid软件包react@15.2.1不满足其兄弟姐妹的peerDependencies要求!

Reading on the internet, I followed an advice to update npm itself to v.3, so I did it by running npm install -g npm . 在互联网上阅读时,我遵循了将npm本身更新到v.3的建议,因此我通过运行npm install -g npm做到了这一点。 But the error is still there: 但是错误仍然存​​在:

+-- UNMET PEER DEPENDENCY react@15.2.1 +-未知的对等依赖react@15.2.1

I assume, that I need to update react to v.15.2.1 , but don't know how to do it. 我认为,我需要更新对v.15.2.1 ,但不知道该怎么做。 Running npm update doesn't help, still same error. 运行npm update没有帮助,仍然是相同的错误。 Could you please advice, how to solve the issue? 您能否请教,如何解决这个问题?

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

Thanks. 谢谢。

The version message is the other way around to what you're thinking. 版本信息是您正在考虑的另一种方式。 It's saying "the version of react that you have is 15.2.1 and that doesn't match what react-typist needs". 意思是“您拥有的react版本是15.2.1,与react-typist需求不匹配”。

Indeed if you look in the react typist package.json you'll see that they require version 0.14 of React. 确实,如果您查看react打字员package.json您会发现它们需要React的0.14版本。 That's the problem. 那就是问题所在。 Looks like the repo hasn't been touched for almost a year, so you might want to pick something else, or fork it and make some changes. 看起来回购协议已经有将近一年没有被修改过了,所以您可能想选择其他东西,或者将其分叉并进行一些更改。

EDIT: If you want to update your npm package, you should do the following. 编辑:如果要更新您的npm包,则应执行以下操作。

On your package.json file look for the line: package.json文件中查找以下行:

"react": "^15.2.0",

change the version number 15.2.0 to 15.2.1 and run npm install . 将版本号15.2.0更改为15.2.1并运行npm install It'll update your react to 15.2.1 . 它将更新您对15.2.1的反应。

But the main detail you should have included in your question is the following warning: 但是,您应该在问题中包括的主要细节是以下警告:

react-typist@0.3.0 requires a peer of react@^0.14 but none was installed.

The recommended method is the one David Gilbertson suggested: 推荐的方法是David Gilbertson建议的方法:

Indeed if you look in the react typist package.json you'll see that they require version 0.14 of React. 确实,如果您查看react打字员package.json,您会发现它们需要React的0.14版本。 That's the problem. 那就是问题所在。 Looks like the repo hasn't been touched for almost a year, so you might want to pick something else, or fork it and make some changes. 看起来回购协议已经有将近一年没有被修改过了,所以您可能想选择其他东西,或者将其分叉并进行一些更改。

If you really want to use this component and function properly, you'll have to downgrade to react 0.14 , which isn't recommended. 如果您确实想使用此组件并正常运行,则必须降级以react 0.14 ,不建议这样做。

To downgrade use: npm install --save react@^0.14 降级使用: npm install --save react@^0.14

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM