2

Is there npm or yarn command to show which version of dependency is installed in my project?

yarn info show my the version that exist in the npm registry. for example I set jest to be: "jest": "27.5.1" but when I run yarn info jest version it show me 28.1.0

I know I can open the lock file, but is hard to handle that.

Jon Sud
  • 10,211
  • 17
  • 76
  • 174
  • For npm `cd` to your project directory then use the [npm ls](https://docs.npmjs.com/cli/v8/commands/npm-ls) command, e.g. `npm ls `. Note you can also include the [--depth](https://docs.npmjs.com/cli/v8/commands/npm-ls#depth) option to list only the top level instance of the dependency, e.g. `npm ls --depth 0`. For modern Yarn use the [why](https://yarnpkg.com/cli/why) command and for older versions of yarn use the [yarn list](https://classic.yarnpkg.com/lang/en/docs/cli/list/) command, e.g. `yarn list --pattern --depth=0` – RobC May 27 '22 at 06:44
  • Does this answer your question? [Find the version of an installed npm package](https://stackoverflow.com/questions/10972176/find-the-version-of-an-installed-npm-package) – RobC May 27 '22 at 07:48
  • ... and [this post](https://stackoverflow.com/questions/60454251/how-to-know-the-version-of-currently-installed-package-from-yarn-lock) for yarn? – RobC May 27 '22 at 07:51

1 Answers1

2

In node package manager simply use :

 npm view <package_name> version

current installed version :

 npm list <package_name>

Yarn :

yarn info <package_name> version
Nazmul Tanvir
  • 49
  • 1
  • 6
  • 2
    no. those commands are show my the version that exist in the npm registry. for example I set `jest` to be: `"jest": "27.5.1"` but when I run `yarn info jest version` it show me `28.1.0` – Jon Sud May 27 '22 at 06:24
  • 2
    use npm list to see current version – Nazmul Tanvir May 27 '22 at 07:07