I am creating a package with some native code, which will be installed globally, and now I see the following behavior:
node-gyp rebuildruns automatically on localnpm installand when the package is installed itself.- When I add a custom
preinstallscript to thepackage.json, it isn't invoked anymore onnpm installnor when the package is installed globally, so it's not compiled at all. - However, in case of
yarn installnode-gyp rebuildstill runs even with apreinstallhook. - Moreover, if I add
"preinstall": "node-gyp rebuild",yarnruns my script and then invokesnode-gyp rebuildagain, so it is compiled twice.
I wonder is there any documentation describing this behavior? Cause I found nothing. I even didn't find an explicit mention that node-gyp rebuild runs automatically on npm install.
And how can I use the preinstall hook so that my module is compiled only once both for npm and yarn?
npm 6.14.6
yarn 1.22.4