5

What is the right way of removing the entire node_modules directory. Do i have to delete it right away

TheBAST
  • 2,680
  • 10
  • 40
  • 68

4 Answers4

3

Ultimately you will need the modules for the application to work (if they are not development dependencies)...

If you want to erase modules you installed for development and not required in production then you can use npm prune.

Also, if you're using git you can add /node_modules to the .gitignore file, so you aren't saving libraries to your repo, and then later you can install dependencies by running npm install.

Community
  • 1
  • 1
upful
  • 850
  • 10
  • 26
  • I"ve already deleted my node_modules in my project directory. Is it alright? – TheBAST Mar 11 '17 at 18:35
  • 1
    should be fine, just run `npm install` to get it back when nothing works :) – upful Mar 11 '17 at 18:42
  • @upful Just a note that Node isn't strictly required for Laravel to work. It powers some optional stuff like the Vue integrations and Laravel Mix, but it's entirely possible to have a Laravel project with no Node modules. – ceejayoz Mar 12 '17 at 00:47
  • True, I guess I assumed they were using some production dependencies... if it's only development dependencies it should work fine without the `/node_modules` – upful Mar 12 '17 at 00:55
1

i lost count on how many times i deleted node_modules just by pressing delete button. Had no problem so far, as long as you don't forget to

npm install

everytime you delete node_modules to install dependency that is required by your app.

Jayakusuma
  • 39
  • 4
1

Best way which i found,in root of app from cmd rmdir /S node_modules and thats it.

Goran_Ilic_Ilke
  • 812
  • 12
  • 16
0

you can use rm -rf /node_modules to remove this from project

deirdreamuel
  • 609
  • 8
  • 11