Searching a project with find also searches every dependency folder. -prune stops find from descending into it.
find . -name node_modules -prune -o -type f -name '*.js' -print
Read it as: if the name is node_modules, prune it, otherwise (-o) test for files ending in .js and print them. The explicit -print is needed, because without it the pruned directory is printed as well. -prune does nothing when -depth is in effect, and -delete turns -depth on, so pruning and deleting in one command does not work. The same pattern works for .git or any cache folder that you want to leave out.
Further reading: find manual page