npm 查找包的版本_查找npm软件包的安装版本

npm 查找包的版本

To see the latest version of all the npm package installed, including their dependencies:

要查看已安装的所有npm软件包的最新版本,包括它们的依赖性:

npm list

Example:

例:

❯ npm list
/Users/flavio/dev/node/cowsay
└─┬ cowsay@1.3.1
  ├── get-stdin@5.0.1
  ├─┬ optimist@0.6.1
  │ ├── minimist@0.0.10
  │ └── wordwrap@0.0.3
  ├─┬ string-width@2.1.1
  │ ├── is-fullwidth-code-point@2.0.0
  │ └─┬ strip-ansi@4.0.0
  │   └── ansi-regex@3.0.0
  └── strip-eof@1.0.0

You can also just open the package-lock.json file, but this involves some visual scanning.

您也可以只打开package-lock.json文件,但这涉及到一些可视扫描。

npm list -g is the same, but for globally installed packages.

npm list -g是相同的,但对于全局安装的软件包。

To get only your top-level packages (basically, the ones you told npm to install and you listed in the package.json), run npm list --depth=0:

要仅获取顶级软件包(基本上是您告诉npm并在package.json npm list --depth=0 ),请运行npm list --depth=0

❯ npm list --depth=0
/Users/flavio/dev/node/cowsay
└── cowsay@1.3.1

You can get the version of a specific package by specifying the name:

您可以通过指定名称来获取特定软件包的版本:

❯ npm list cowsay
/Users/flavio/dev/node/cowsay
└── cowsay@1.3.1

This also works for dependencies of packages you installed:

这也适用于您安装的软件包的依赖项:

❯ npm list minimist
/Users/flavio/dev/node/cowsay
└─┬ cowsay@1.3.1
  └─┬ optimist@0.6.1
    └── minimist@0.0.10

If you want to see what’s the latest available version of the package on the npm repository, run npm view [package_name] version:

如果要查看npm存储库上软件包的最新可用版本,请运行npm view [package_name] version

❯ npm view cowsay version

1.3.1

翻译自: https://flaviocopes.com/npm-know-version-installed/

npm 查找包的版本