Ondrej Tokar Ondrej Tokar - 1 year ago 78
Node.js Question

How can I add all dependencies from node_modules to package.json at once?

Normally I would execute:

npm install <package_name> --save
for each library/module.

However, is there a way to add all packages that are currently in the
folder to the

Answer Source

You can do npm init to create package.json file with all dependencies currently installed, added into it by default. I have npm version 2.11.3.

Earlier versions of npm used to create a package.json file without the dependencies. If you are on such a version, run the below command to save the currently installed dependencies into it:

ls node_modules | xargs npm install --save

Of course, ls & xargs will work only if you are on Linux / Mac OS X.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download