Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove node_modules from git in vscode

Getting error while removing node_modules in git, vscode terminal

 git rm -r --cached node_modules 

Error:

fatal error: pathspec 'node_modules' did not match any files

like image 894
Mano Avatar asked Jun 04 '18 07:06

Mano


People also ask

How do I remove node_modules?

Just Open your root folder with VSCode. Select node_modules folder and delete. Profit. (It will take few milliseconds to delete.)

Can node_modules folder be deleted?

Anybody can suggest if I delete node_modules folder and after re-creating it, will I get all the already installed packages back in the same way they were just before deleting? YES, you will get back all the packages listed in your package. json file.

Do I need node_modules in git?

Not committing node_modules implies you need to list all your modules in the package. json (and package-lock. json ) as a mandatory step. This is great because you might not have the diligence to do so, and some of the npm operations might break if you don't.


2 Answers

  1. make .gitignore file.
  2. add node_modules/ line to gitignore file
  3. run this command git rm -r --cached . git add . git commit -m "remove gitignore files" git push
like image 134
Karavolt Avatar answered Sep 27 '22 02:09

Karavolt


I faced the same issue. Do the below steps -

  • Make .gitignore file.
  • Run below commands in your terminal

    git rm -r --cached node_modules

    git commit -am "node_modules be gone!"

    git push origin master

That's all!

You are good to go!

like image 35
Sheena Singla Avatar answered Sep 25 '22 02:09

Sheena Singla