【问题标题】:Different commands give different npm versions when check for installed npm version检查已安装的 npm 版本时,不同的命令会给出不同的 npm 版本
【发布时间】:2021-02-24 04:33:20
【问题描述】:

按照这个SO Solution我累了安装react-native-calendars的具体版本如下,

npm install react-native-calendars@1.212.0

安装完成后,我可以像这样在 package.json 中看到它

"react-native-calendars": "^1.212.0"

这表明安装了所需的鹿肉。

当我运行npm view react-native-calendars version 时,结果是1.1252.0——这是react-native-calendars 的最新版本。

当我运行npm list react-native-calendars 时,结果是-- react-native-reanimated@1.13.2

  1. 什么是npm 命令用于检查已安装的npm package 版本?

【问题讨论】:

    标签: react-native npm


    【解决方案1】:

    npm view 显示远程 NPM 存储库中的包。

    npm list 显示安装的软件包版本。

    package.json 显示要使用的包版本范围。

    npm list 中的 -- ... 在树中显示它的依赖关系。要查看只是包,请使用npm list package --depth=0

    【讨论】:

    • 所以,npm view <Package name> versionnpm view <package name> versions 都提供了两个远程版本,对吧!那么这两个命令有什么区别呢?
    【解决方案2】:

    我可以看到您正在使用npm list,这是检查节点模块版本的正确命令。但奇怪的是,它返回的版本与 json 包中提到的不同。所以我认为你需要做 3 件事。

    1: Uninstall the package completely.
    2: Clean gradlew cache and install the module again mentioning specific version number and check again.
    3: Start npm with --reset-cache.
    

    【讨论】:

      猜你喜欢
      • 2017-06-24
      • 2012-06-13
      • 1970-01-01
      • 2022-08-18
      • 2014-07-19
      相关资源
      最近更新 更多