I actually don't know if the default path from a terminal is also the default path for an Execute Shell Script action. You should check both and compare results. I'm just an average guy here, not one of the elite wizards who knows everything. There's a fair chance this is the cause of your problem.
I would speculate that you manually edited the path in your Terminal window but may have forgotten about that change. And we can see from your action that you didn't edit the path to include the path for npm. This sort of thing has happened to be before. In fact this is the reason I hate using external commands, because every time an app updates its version number it may update the pathname for its executable, resulting in me have to change my macros.