Modify package.json before npm install is run

Note that, preinstall should work. That’s not a Netlify thing to change. It’s handled by npm - the same npm that you run locally. If your local npm runs preinstall, the same should happen on Netlify.

Except in the situation where we restore your node modules from our build cache. In that case, since no npm install is run (we run it if it’s needed, we skip it otherwise), preinstall would not run either.

However, it sounds like you’re reinventing the wheel, because the problem that you’re actually trying to solve already has a solution: [Support Guide] Using private NPM modules on Netlify