【问题标题】:Unable to install dependencies through npm无法通过 npm 安装依赖项
【发布时间】:2022-01-05 17:07:13
【问题描述】:

我不知道为什么,但是升级节点后 我无法安装 docz 依赖项:( 遵循这些步骤..

  1. npx create-react-app 项目名称
  2. cd 项目名称
  3. npm install docz

但我收到了这些错误。

npm install docz
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: test@0.1.0
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR!   react@"^17.0.2" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0" from docz@2.3.1
npm ERR! node_modules/docz
npm ERR!   docz@"*" 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\HP\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\HP\AppData\Local\npm-cache\_logs\2022-01-05T13_47_05_954Z-debug-0.log

请帮助我,我尝试了所有可能的事情,但不明白我在哪里缺乏。 实际上,我认为这是我的 NPM 的问题,所以尝试安装 yarn 但是现在这个错误!!

$ npm install --global yarn

changed 1 package, and audited 2 packages in 3s

found 0 vulnerabilities

HP@LAPTOP-P6Q3FNJ2 MINGW64 ~/Desktop (master)
$ yarn --version
C:\Users\HP\AppData\Roaming\npm/node_modules/node/bin/node: line 1: This: command not found

【问题讨论】:

  • npm 错误!解决时:test@0.1.0 这个包是什么?如果您不需要它,请尝试从 package.json 中删除它并再次执行“npm install”

标签: node.js reactjs npm yarnpkg


【解决方案1】:

它看起来有问题,因为反应版本不匹配。

尝试的一种解决方案是将--legacy-peer-deps 添加到命令的末尾。 npm install docz --legacy-peer-deps

【讨论】:

    猜你喜欢
    • 2018-05-30
    • 1970-01-01
    • 2017-06-03
    • 1970-01-01
    • 2021-09-20
    • 1970-01-01
    • 2018-12-16
    • 2020-02-23
    • 1970-01-01
    相关资源
    最近更新 更多