First of all, your statement doesn't make sense:
echo ${OUTPUT} | grep "_currentUrl" *
The asterisk expands to the files in the working directory, and grep is searching the pattern there, ignoring what comes from stdin. I have no idea what you intended with *
.
Then, you didn't specify whether you need the full output of npm later on. Assuming that you don't, you can write
npm run generate_post | grep _currentUrl
Of course it might be wise to follow the advice by Triptych to capture stderr too, but this is a different story.
If you do need the full output of npm, consider putting it into a file instead of a variable - of course this depends on how you are going to use it later, so this is just one of several options:
npm run generate_post | tee npm_output.txt | grep _currentUrl