To list the npm packages that you have installed in your project, you can use the npm list
command. This command lists all of the dependencies and devDependencies in your project, as well as their dependencies, recursively.
Here’s an example of how to list all of the npm packages in your project:
npm list
This command will list all of the packages in your project, as well as their version numbers and where they are installed.
If you want to list only the top-level dependencies and devDependencies in your project, you can use the --depth=0
flag:
npm list --depth=0
This command will list only the packages that are directly required by your project, without listing their dependencies.
You can also use the npm list --json
command to output the list of packages in JSON format, which you can then parse and manipulate in your code.
npm list --json
Note: The npm list
command only lists the packages that are installed in your project. If you want to list all of the npm packages that you have installed globally on your system, you can use the npm list -g
command.