npm thinks my modules are “extraneous”

The command

npm ls

lists the modules in your project. Trouble is I didn’t know that modules installed via

npm install [module name]

are considered extraneous since they are not listed in your package.json.

Instead, list your dependencies in package.json and use simply

npm install

and all your dependcies will be installed (just like before) but npm will not consider them extraneous.

If you’re coming from the Ruby work, what I was originally doing seems to be similar to installing gems via the `gem` command instead of putting them in a Gemfile and using bundler. Now, if only there was a node equivalent to Bundler…

This is what my `npm ls` was originally report. Emphasis mine.

serial-viz@0.0.1 /Users/chris/Projects/UMD/838f/1_viz_with_node
├── consolidate@0.10.0 extraneous
├─┬ express@3.4.8
│ ├── buffer-crc32@0.2.1
│ ├─┬ commander@1.3.2
│ │ └── keypress@0.1.0
│ ├─┬ connect@2.12.0
│ │ ├── batch@0.5.0
│ │ ├── bytes@0.2.1
│ │ ├─┬ multiparty@2.2.0
│ │ │ ├─┬ readable-stream@1.1.10
│ │ │ │ ├── core-util-is@1.0.1
│ │ │ │ ├── debuglog@0.0.2
│ │ │ │ └── string_decoder@0.10.25
│ │ │ └── stream-counter@0.2.0
│ │ ├── negotiator@0.3.0
│ │ ├── pause@0.0.1
│ │ ├── qs@0.6.6
│ │ ├── raw-body@1.1.2
│ │ └── uid2@0.0.3
│ ├── cookie@0.1.0
│ ├── cookie-signature@1.0.1
│ ├── debug@0.7.4
│ ├── fresh@0.2.0
│ ├── merge-descriptors@0.0.1
│ ├── methods@0.1.0
│ ├── mkdirp@0.3.5
│ ├── range-parser@0.0.4
│ └─┬ send@0.1.4
│ └── mime@1.2.11
├── mustache@0.8.1 extraneous
└─┬ serialport@1.3.1 extraneous
├── async@0.1.18
├── bindings@1.1.1
├── nan@0.7.1
├─┬ optimist@0.3.7
│ └── wordwrap@0.0.2
└── sf@0.1.6