简体   繁体   English

安装 npm react-facebook-login 时出现“ERESOLVE 无法解析依赖树”

[英]"ERESOLVE unable to resolve dependency tree" when installing npm react-facebook-login

Trying to install npm react-facebook-login in my react app, but I keep getting dependency errors?尝试在我的 React 应用程序中安装npm react-facebook-login ,但我不断收到依赖项错误? That sounds scary and I don't want to force install something that can potentially break in the future.这听起来很可怕,我不想强制安装将来可能会损坏的东西。 I'm new to javascript, what are some ways I should proceed?我是 javascript 的新用户,我应该采取哪些方式?

I've tried clearing my npm cache and removing node modules and installing them again, however im still getting this error.我已经尝试清除我的 npm 缓存并删除节点模块并再次安装它们,但我仍然收到此错误。

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: buckets@0.1.0
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR!   react@"^17.0.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.0.0" from react-facebook-login@4.1.1
npm ERR! node_modules/react-facebook-login
npm ERR!   react-facebook-login@"*" 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 /home/user/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2021-01-03T12_23_40_000Z-debug.log

debug log : debug log

0 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install', 'react-facebook-login' ]
1 info using npm@7.0.15
2 info using node@v15.4.0
3 timing config:load:defaults Completed in 4ms
4 timing config:load:file:/usr/lib/node_modules/npm/npmrc Completed in 12ms
5 timing config:load:builtin Completed in 12ms
6 timing config:load:cli Completed in 1ms
7 timing config:load:env Completed in 1ms
8 timing config:load:file:/home/user/app/frontend/buckets/.npmrc Completed in 0ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:/home/user/.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:/usr/etc/npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 1ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 21ms
19 verbose npm-session a80715ea0624d48b
20 timing npm:load Completed in 30ms
21 timing arborist:ctor Completed in 1ms
22 timing idealTree:init Completed in 1531ms
23 timing idealTree:userRequests Completed in 4ms
24 silly idealTree buildDeps
25 silly fetch manifest react-facebook-login@*
26 http fetch GET 200 https://registry.npmjs.org/react-facebook-login 2249ms
27 silly fetch manifest react@^17.0.1
28 http fetch GET 200 https://registry.npmjs.org/react 142ms
29 timing idealTree Completed in 3940ms
30 timing command:install Completed in 3944ms
31 verbose stack Error: unable to resolve dependency tree
31 verbose stack     at Arborist.[failPeerConflict] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1045:25)
31 verbose stack     at Arborist.[loadPeerSet] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1025:36)
31 verbose stack     at async Arborist.[buildDepStep] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:781:11)
31 verbose stack     at async Arborist.buildIdealTree (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:209:7)
31 verbose stack     at async Promise.all (index 1)
31 verbose stack     at async Arborist.reify (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:122:5)
31 verbose stack     at async install (/usr/lib/node_modules/npm/lib/install.js:39:3)
32 verbose cwd /home/user/app/frontend/buckets
33 verbose Linux 5.4.0-58-generic
34 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "react-facebook-login"
35 verbose node v15.4.0
36 verbose npm  v7.0.15
37 error code ERESOLVE
38 error ERESOLVE unable to resolve dependency tree
39 error
40 error While resolving: [1mbuckets[22m@[1m0.1.0[22m
40 error Found: [1mreact[22m@[1m17.0.1[22m[2m[22m
40 error [2mnode_modules/react[22m
40 error   [1mreact[22m@"[1m^17.0.1[22m" from the root project
40 error
40 error Could not resolve dependency:
40 error [35mpeer[39m [1mreact[22m@"[1m^16.0.0[22m" from [1mreact-facebook-login[22m@[1m4.1.1[22m[2m[22m
40 error [2mnode_modules/react-facebook-login[22m
40 error   [1mreact-facebook-login[22m@"[1m*[22m" from the root project
40 error
40 error Fix the upstream dependency conflict, or retry
40 error this command with --force, or --legacy-peer-deps
40 error to accept an incorrect (and potentially broken) dependency resolution.
40 error
40 error See /home/user/.npm/eresolve-report.txt for a full report.
41 verbose exit 1

How can I overcome this without causing any future problems?我怎样才能克服这个问题而不引起任何未来的问题? Thank you for the help.感谢您的帮助。

This error comes from version 7.x of npm.此错误来自 npm 的 7.x 版本。 Please try again adding the --legacy-peer-deps option, as follows:请再次尝试添加--legacy-peer-deps选项,如下所示:

npm install react-facebook-login --legacy-peer-deps

Since npm install seems broked i tried:由于npm install似乎坏了我试过:

yarn install

And it works!它有效!

Thanks谢谢

you can use this:你可以使用这个:

npm install angular-google-charts --legacy-peer-deps

or like this, if you want to save:或者像这样,如果你想保存:

npm install --save angular-google-charts --legacy-peer-deps

I started getting the error (below) after upgrading npm from version 6 to 7.在将npm从版本 6 升级到 7 后,我开始收到错误(如下)。

npm ERR! npm 错误! code ERESOLVE npm ERR!代码 ERESOLVE npm 错误! ERESOLVE unable to resolve dependency tree ERESOLVE 无法解析依赖树

... ...

npm ERR, Fix the upstream dependency conflict, or retry this command with --force. npm ERR,修复上游依赖冲突,或者用--force重试这个命令。 or --legacy-peer-deps to accept an incorrect (and potentially broken) dependency resolution.或 --legacy-peer-deps 接受不正确(并且可能损坏)的依赖解决方案。

In my case, using either --legacy-peer-deps or --force resulted in a useless bundle.就我而言,使用--legacy-peer-deps--force会导致一个无用的捆绑包。

So I tried deleting the node_modules , package-lock.json , and bundle using yarn install .所以我尝试删除node_modulespackage-lock.json ,并使用yarn install捆绑。 This generated a yarn.lock file and created a new package-lock.json that seemed to work fine in subsequent npm runs.这生成了一个 yarn.lock 文件并创建了一个新的 package-lock.json 似乎在随后的 npm 运行中工作正常。

ps This is a temporary workaround until npm 7 works fine. ps 这是一个临时的解决方法,直到npm 7 工作正常。 After that, I will delete yarn.lock, package-lock.json and node_modules, and re-bundle using npm .之后,我将删除 yarn.lock、package-lock.json 和 node_modules,并使用npm重新捆绑。

rm -rf node_modules
rm package-lock.json 
yarn install 
# generates a yarn.lock file and a new package-lock.json

# continue with npm 
npm start
@react-native-firebase/app@12.6.1
├── @react-native-firebase/auth@12.6.1
├── @react-native-firebase/firestore@12.7.1

Notice that firestore has a version of 12.7.1 and all other has 12.6.1 , as firestore is a peer of other modules, to maintain consistency, it is also ought to be of the same version as it's peers, when that doesn't happens then you result in the error you have mentioned,请注意,firestore 的版本为12.7.1 ,所有其他的版本为12.6.1 ,因为 firestore 是其他模块的对等模块,为了保持一致性,它也应该与它的对等模块具有相同的版本,但事实并非如此发生然后你会导致你提到的错误,

until the first number of the version doesn't changes, you can use --legacy-peer-deps and the result will be somewhat above [get the list of packages installed using npm ls --depth=0 ,直到版本的第一个数字没有改变,您可以使用 --legacy-peer-deps 并且结果将略高于 [获取使用npm ls --depth=0安装的软件包列表,

however if you want all of them to be of the same version, you can do the following但是,如果您希望它们都具有相同的版本,则可以执行以下操作

  • type npm update and all the packages will be updated to the latest version, the version will be mostly in which the second number changes.类型npm update ,所有的包都会更新到最新版本,版本大多是第二个数字变化的。 you can also use npm update with the specific package to only update the one you want to in order to resolve the error.您也可以使用npm update和特定的 package 来仅更新您想要的更新以解决错误。

  • install the specific version of the module by npm install [package-name]@[version-number]通过npm install [package-name]@[version-number]模块的具体版本

npm i react-facebook-login --force npm i react-facebook-login --force

Simply adding --force help me to resolve this error.只需添加--force即可帮助我解决此错误。

yarn install --force

on the command, you are running just add on this --legacy-peer-deps在命令上,您正在运行只需添加此--legacy-peer-deps

for me, the command was对我来说,命令是

npm install @reduxjs/toolkit react-redux

then I added然后我添加了

npm install @reduxjs/toolkit react-redux --legacy-peer-deps

and then boom it works然后繁荣它工作

Try running尝试运行

npm update

especially if the error is a result of a firebase package that may be having a version that is outdated thus conflicting with its peers.特别是如果错误是 firebase package 的结果,该错误可能具有过时的版本,因此与其同行冲突。 Solved my issue as suggested by @snehal按照@snehal 的建议解决了我的问题

Use this at the end --force, or --legacy-peer-deps最后使用 --force 或 --legacy-peer-deps

Eg:-例如:-

npm install --force

or或者

npm install --legacy-peer-deps

I face this challenge too, and I was trying to run my react.js application.我也面临这个挑战,我试图运行我的 react.js 应用程序。

I have solved it by running: npm install --legacy-peer-deps我通过运行解决了它: npm install --legacy-peer-deps

After It started as normal正常开始后

Maybe you are trying to install the packages into a wrong file path.也许您正在尝试将软件包安装到错误的文件路径中。

For me works removing node_modules and run:对我来说,删除 node_modules 并运行:

npm install

I was stuck running npm install but didn't work.我被困在运行npm 安装但没有工作。 Then I used the --legacy-peer-deps along with npm install command.然后我使用了--legacy-peer-deps和 npm 安装命令。 It resolved my problem.它解决了我的问题。

npm install --legacy-peer-deps npm 安装 --legacy-peer-deps

There is a good chance that you have updated your npm after creating the app.您很有可能在创建应用程序后更新了 npm。 So, your node_modules and package-lock.json isn't compatible to the updates.因此,您的 node_modules 和 package-lock.json 与更新不兼容。 So, you have to re-install this two files:因此,您必须重新安装这两个文件:

rm node_modules
rm package-lock.json
npm install

Try this code, and you should be fine:试试这段代码,你应该没问题:

npm install --save react-typical --legacy-peer-deps npm install --save react-typical --legacy-peer-deps

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

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