You may be able to do this using rsync alone, however I'd find it easier to do with find + rsync:
find /www -type f -not -path '/www/*/node_modules/*' -name 'index.js' -print0 |
rsync --dry-run --files-from=- --from0 -v / /testbackup
Remove --dry-run if you're happy with the result.
Note: you're using -r instead of the "standard" -a; from that I gather you don't want to turn on all the options normally turned on by -a. So this command won't either.
% tree /www
/www
├── proj-1
│ └── index.js
├── proj-10
│ └── node_modules
│ └── index.js
├── proj-2
│ └── index.js
├── proj-3
│ └── index.js
├── proj-4
│ └── index.js
├── proj-5
│ └── index.js
├── proj-6
│ └── node_modules
│ └── index.js
├── proj-7
│ └── node_modules
│ └── index.js
├── proj-8
│ └── node_modules
│ └── index.js
└── proj-9
└── node_modules
└── index.js
16 directories, 10 files
% find /www -type f -not -path '/www//node_modules/' -name 'index.js' -print0 |
rsync --dry-run --files-from=- --from0 -v / target
building file list ... done
www/
www/proj-1/
www/proj-1/index.js
www/proj-2/
www/proj-2/index.js
www/proj-3/
www/proj-3/index.js
www/proj-4/
www/proj-4/index.js
www/proj-5/
www/proj-5/index.js
sent 292 bytes received 49 bytes 682,00 bytes/sec
total size is 0 speedup is 0,00 (DRY RUN)