To dispel any weirdness regarding packages (which happens to me too), it's best to delete node_modules
folder and npm i
again. After that, combination of dependencies in your package.json
(both dev-dependencies and normal-ones), should match the output of the command: npm ls --depth="0"
.
Now, on both your PC and your laptop the npm ls --depth="0"
will match the combined list of all dependencies in package.json
. Both cannot mismatch, otherwise that would mean npm became self-conscious and went rogue .
Now, the readers of SO down-voted your question assuming you don't understand that dependencies can have dependencies and that's where the folders are coming from.
I hope that's not the case and that you will not get discouraged by any negativity happening in SO.
There is another possible scenario which might explain your case.
If you forgot to add --save
when installing dependencies, dependencies were just saved into node_modules
folder, but not added to your package.json
. Thus, you might have inadvertently installed more things that you use.
When you delete the node_modules
folder and install again, all dependencies are wiped and only what was in package.json is installed. That's why I suggest to delete node_modules
folder first. As a note, npm-publishing automation libraries like my preferred np tend to wipe and reinstall dependencies before publishing the npm packages because of this exact reason. There can be "rubbish" in node_modules
and wipe/reinstall helps.
I suggest to refer to this brilliant answer on --save
.
With regards of previous answers, Jonathan mentioned npm ls
but I find it unwieldy on anything else than trivial libraries — too much scrolling. It's best to use npm ls --depth="0"
to check just the topmost level of your dependencies.