I've installed a couple of packages here in my local machine, but I'm not able to know which ones I've installed.
Is there some framework to show me which packages and version are installed in my project (not-saved, saved and dev saved)?
I tried to compare the node_modules folders but the results are not very precise.
A package.json file: lists the packages your project depends on specifies versions of a package that your project can use using semantic versioning rules makes your build reproducible, and therefore easier to share with other developers
You can create a package.json file by running a CLI questionnaire or creating a default package.json file. To create a package.json file with values that you supply, use the npm init command. On the command line, navigate to the root directory of your package.
The package.json file is the heart of Node.js system. It is the manifest file of any Node.js project and contains the metadata of the project. The package.json file is the essential part to understand, learn and work with the Node.js.
If you want to include package author information in "author" field, use the following format (email and website are both optional): You can create a package.json file by running a CLI questionnaire or creating a default package.json file. To create a package.json file with values that you supply, use the npm init command.
What you want is npm list
(npm ls
is handy alias).
Assuming you ran:
npm init
npm install -S postcss
npm install -D postcss-cli
npm install postcss-import
Then if you run npm list --depth 0
, npm will print:
[email protected] /home/.../my-package
├── [email protected]
├── [email protected]
└── [email protected] extraneous
npm ERR! extraneous: [email protected] /home/.../my-package/node_modules/postcss-import
All the packages marked with extraneous
have been installed, but not added to package.json
.
By default, npm list
prints a full dependency graph. The --depth
option limits the graph to the specified number of layers. --depth 0
only prints the direct dependencies, not their dependencies, so that's what you want in this case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With