package.json generation / npm unused packages package.json generation / npm unused packages javascript javascript

package.json generation / npm unused packages


  1. I am using Mocha.

  2. npm init

  3. npm ls will list "extraneous" next to ones that are not in your package.json. But, it sounds like you don't have a package.json yet.


Basically, your workflow is very backward. Here is how it is intended to work:

  1. Start a new project with npm init. It has no dependencies.
  2. Oh, I want to start using a package, say express? Add it to package.json under dependencies, then run npm install.
  3. Oh, I want to start using a package for development, say mocha? Add it to package.json under devDependencies, then run npm install.

You seem to have some existing code with manually-installed packages (via npm install <packageName>), which is a mess. I suggest starting over and following the above workflow.


To answer the third question:

npm prune

will remove all installed modules that are no longer mentioned in your package.json.


And you should really have asked 3 separate questions.


  1. I am also using Mocha. It has code coverage, BDD, TDD, runs in browser. It is pretty complete and also heavily maintained by I think one of the most brilliant javascript/node.js programmers named TJ.

  2. It is almost impossible to guess which version(s) to use. Because npm does not know which version breaks which dependencies. You could probably install all dependencies using something like node-detective. Then you can just install them using npm.js from within javascript. Maybe I would like to tackle this in the future.

  3. I would also probably delete all dependencies , next install needed dependencies back using step(2). But also disc-space is not such a big case anymore with the current HDs.

P.S: I think I also agree with Domenic