npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

How to run script before all other scripts

I support several different node applications, with different node versions being used in production. So, I need to always be sure I’m using the node version in production for any particular application. I was hoping to define a npm script that is executed automatically before other npm scripts but there’s only a small handful available and seemingly no way to do it before any custom npm script.

I thought “npm hook scripts” would work, but this appears to not run for my own application.

Short of starting every custom npm script with “npm run set-node-version” or something, are there any options?