Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a list of packages not saved to package.json?

Tags:

npm

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.

like image 913
Fabio Picheli Avatar asked Mar 07 '17 20:03

Fabio Picheli


People also ask

What is a package JSON file?

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

How do I create a JSON package in NPM?

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.

What is a JSON file in Node JS?

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.

How do I include package author information in the package form?

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.


1 Answers

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.

like image 188
RyanZim Avatar answered Sep 23 '22 20:09

RyanZim