What is the purpose of node_modules folder in rails 6?
node_modules is not rails specific actually.
Since rails 6 is using webpack as the assets manager instead of sprockets, you get this node_modules folder with all dependencies of the libs specified in you package.json file.
It is created when using the npm or yarn command to download and host in your project all the javascript libraries required by your project.