'gitignore file doesn't ignore node_modules folder [duplicate]

I'm using VS Code for my project and I don't want node_modules folder to be commited in my repository, so I created a .gitignore file to add that folder, but when I make another commit node_modules is still there and git gives me an error when I make a push:

remote: error: File Proyecto2/node_modules/canvas/build/Release/librsvg-2.so.2 is 100.20 MB; this exceeds GitHub's file size limit of 100.00 MB

I put .gitignore file here

I try to add the folder in 2 ways but none works



Solution 1:[1]

You just need to

git rm -r ./node_modules
git commit -am "Removed 'node_modules' from repo."
git push

And you should be good to go.

If you want to keep your local node_modules intact, change the git rm command to

git rm -r --cached ./node_modules

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 Nicholas Carey