'.gitignore file is not ignoring my node_modules folder

In my gitignore file i have tried some many ways of ignoring the node_modules folder

.gitignore - file ./node_modules /node_modules node_modules

project structure

  • node_modules
  • public
  • src
  • .gitignore


Solution 1:[1]

In cases where /node_modules in your .gitignore file doesn't work, I suggest this:

git rm -r --cached node_modules

enter the above command before you git push to your repositories

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SwissCodeMen