isaacs/npm — Issue #1746: Generate dependencies hash from node_modules
Author: TrevorBurnham
Created: 2011-11-21 15:53:41+00:00
State: open

Currently I find myself doing several `npm install x` and `npm uninstall y`s during development, and I have to update the `package.json` by hand afterward to reflect the changes. It would save me some time if there were a command to do the inverse of `npm install`: It would look at all of the modules that live at root-level in the local `node_modules` and update the `dependencies` hash in the local `package.json` file accordingly.

Obviously such a command wouldn't be 100% accurate (it couldn't distinguish between `dependencies` and `devDependencies`, for instance)... an alternative solution would be a flag for `npm ls` that would provide output that could be copy+pasted into `package.json`, i.e.

> npm ls -json
{
"express": "2.5.1",
"jade": "0.17.0"
}