There is already a node_modules folder. How to generate package.json according to the modules in the folder?

  node.js, question


The current situation is that a lot of node_modules are installed, but I don’t know why when installing, package.json is not updated automatically. Now there are two problems.

1.package.json did not update automatically because cnpm was used or because –save was not added after npm install was not added?
2. Can package.json be automatically generated through existing modules?

Thank you ~

  1. If you mean that the newly installed package does not appear in the dependencies or devDependencies inside of package.json, it is because there is no parameter-save or –save-dev added during installation.

  2. Node4 is almost impossible in the future, because the new npm has made “pat optimization” according to the dependency structure. The package under node_modules you see can no longer confirm whether it is your own dependency or the dependency