0

I have added many packages in my Project using npm.

But after while cleaning my Project i was deleted my package.json by mistake.

so for create new package.json file i have run command nmp init.

now i got the package.json but in my package.json file is like below.

{
  "name": "name-will-be-here",
  "version": "0.0.1",
  "description": "description-will-be-here",
  "main": "gulpfile.js",
  " dependencies": {},
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

Is there any commands for fill the details like before it is...?

but my Question is that...

How can i get all details of dependencies and devDependencies which was already there before delete?

Vimal Raiyani
  • 174
  • 2
  • 11
  • 6
    Possible duplicate of [npm - save installed packages as dependencies](http://stackoverflow.com/questions/29276345/npm-save-installed-packages-as-dependencies) – Andrew Li Sep 09 '16 at 05:49
  • You was shared wrong information. Using that command i can see my package.json file code in command line. I want fullfill detail like its before. – Vimal Raiyani Sep 09 '16 at 09:38

1 Answers1

0

Short answer is you cant. Longer answer is that you need to understand how npm 3 works by default and that is to install all dependencies and shared sub dependencies in same top folder so your node_modules holds a lot more than your main dependencies only (unless you used legacy option or older npm).

In future use scm like git or ide history features to revert accidental deletions.

sagie
  • 1,744
  • 14
  • 15
  • So mate, what happened if we cant fill that detail in package.json? Is it create any issue in future or in meantime...? – Vimal Raiyani Sep 09 '16 at 06:31
  • Start doing npm install --save or --save-dev for the modules you need. It will update it based on your needs – sagie Sep 09 '16 at 06:33
  • Whats about past modules details which was i added before delete? – Vimal Raiyani Sep 09 '16 at 06:37
  • Like i siad you will have ti do it again including modules already installed – sagie Sep 09 '16 at 06:39
  • Yes, i know that, but the Question is that they have to make NPM smart enough.. like if you run command NPM init then it will automatically catch all detail from installed packages... what you say? – Vimal Raiyani Sep 09 '16 at 06:44
  • See my original answer that is not pissible to say from node_modules directory – sagie Sep 09 '16 at 06:45
  • Yeah, i have seen that but i am looking for more easy and time saver solution so i am looking and finding another way.. – Vimal Raiyani Sep 09 '16 at 06:48
  • Sorry you didnt like the fact that the answer is no. No reason for a -1 for time spent helping – sagie Sep 09 '16 at 08:55