Override npm install or execute a command before it

I’m trying to modify package.json and delete package-lock.json.
This action is required to install and build project (git repo can’t be modified just to make it work w/ netlify).

You can add "preinstall": "node preinstall-script.js" to package.json.

@aljosa, will the solution posted by @patarapolw work for you?

If not, or if there are other questions, please let us know.

We moved away from Netlify and are now building everything w/ Github actions which includes deploying sites w/ zip file (using netlify api).
Haven’t tried the preinstall hook but I think it would work.
Thanks for suggestions.

Note to future people reading this conversation, preinstall no longer runs before npm install as of npm v7