我正在尝试使用 npm 安装新组件。但它给出了错误

I am trying to install new component using npm. But it gives error

我试图添加 $ npm install react-native-touchable-bounce --save 但它给出了与以下相同的错误。 然后我删除了所有 node_modules 仍然收到此错误。 npm install 给出以下错误。

PS I:\Code\singal res\code\singalRes> npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: undefined@undefined      
npm ERR! Found: react-native-svg@12.1.0
npm ERR! node_modules/react-native-svg
npm ERR!   react-native-svg@"^12.1.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react-native-svg@"^9.13.6" from @ui-kitten/components@5.0.0
npm ERR! node_modules/@ui-kitten/components
npm ERR!   @ui-kitten/components@"^5.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\softb\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\softb\AppData\Local\npm-cache\_logs21-02-14T03_13_39_660Z-debug.log

如果您遇到此类错误,请转至 package.json 并删除 react-native-svg@"^12.1.0" from the root project(您的可能不同)。

然后 运行 npm-install 或者你最好使用 yarn 而不是 npm。纱线就可以了。

问题已解决!

可能是lib版本不匹配,可以删除package-lock.jsonnode_modules, 然后再试一次npm install

对我来说,添加 --force 标志解决了问题

npm i --force