I accidently deleted my package.json file and node modules

58 views Asked by At

I accidentally deleted my package.json file and node modules and now I'm unable to get JSON file I've changed the directory and started fresh also but it didn't work.

enter image description here

I have tried deleting the npm-cache and try to start with a new directory but didn't work I have tried various commands :

  • rm -rf npm-cache
  • npm cache clean --force
1

There are 1 answers

0
Muhammad TS On

You will have to try with:

npm init

Or:

npm init -y

To initialise your project and then add your dependencies using:

npm install <package name>

To populate your package.json file.