【问题标题】:Why does npm install fetch an old version of the package?为什么 npm install 会获取旧版本的软件包?
【发布时间】:2021-10-08 01:23:30
【问题描述】:

我正在尝试运行这个命令:

npm install --save react-highlight-words@0.16.0

失败并显示此消息:

npm install --save react-highlight-words@0.16.0
(node:16708) ExperimentalWarning: The fs.promises API is experimental
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: admin_fe@1.0.0
npm ERR! Found: react@17.0.2
npm ERR! node_modules/react
npm ERR!   dev react@"^17.0.2" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^0.14.0 || ^15.0.0 || ^16.0.0-0" from react-highlight-words@0.16.0
npm ERR! node_modules/react-highlight-words
npm ERR!   react-highlight-words@"0.16.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 /Users/amitruparel/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/amitruparel/.npm/_logs/2021-10-08T01_17_59_650Z-debug.log

但是查看此软件包的 github code:

  "peerDependencies": {
    "react": "^0.14.0 || ^15.0.0 || ^16.0.0-0 || ^17.0.0-0"
  }

它似乎确实支持 React v17(我有)

所以我不明白为什么 npm 不让我安装这个包?

【问题讨论】:

  • 啊,有没有办法检查npm上传的包的package.json文件?

标签: npm npm-install


【解决方案1】:

您正在查看package.json 的master 版本,它实际上可能与0.16.0 版本的版本不对应。

0.16.0 没有标签,但您仍然可以通过...查看该已发布版本的依赖项...

npm view react-highlight-words@0.16.0 peerDependencies

# { react: '^0.14.0 || ^15.0.0 || ^16.0.0-0' }

请注意,v0.16.0 是 over 3 years old。 NPM 上的当前版本是 0.17.0,这可能是你想要的

npm view react-highlight-words peerDependencies

# { react: '^0.14.0 || ^15.0.0 || ^16.0.0-0 || ^17.0.0-0' }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-02
    • 2020-01-13
    • 2017-12-13
    • 1970-01-01
    • 1970-01-01
    • 2014-05-17
    相关资源
    最近更新 更多