npm init doesn't get all packages in node_modules folder

120 Views Asked by At

I have a project with a node_modules folder. Something unexpected happened and i had to delete my package.json and package-lock.json files.
Now i need to get my project's packages and dependencies etc.. into a new package.json file. Unfortunately, running npm init doesn't get all packages that are in the node_modules directory.
For example, react and react-dom are installed and present in node_modules but don't get included in the generated package.json file by npm init; alongside other packages.

What can i do to make all my packages appear in package.json and also if possible in package-lock.json ?

0

There are 0 best solutions below