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 ?
Asked
Active
Viewed 100 times
0

ImportError
- 358
- 5
- 17
-
I don't think git has anything to do with Node, what do you mean exactly? In any case, fFor good or bad, you can get stuff installed into `node_modules` and not added to package.json, that's how npm was designed. – Álvaro González Apr 28 '21 at 11:12
-
@Alvaro Gonzalez Mistake, I meant npm init. My bad – ImportError Apr 28 '21 at 11:14
-
Then I think you're using npm incorrectly. You don't generate "package.json" from "node_modules", it's the other way round. – Álvaro González Apr 28 '21 at 11:16
-
try `npm install` – Kiran Mistry Apr 28 '21 at 11:18