The docs for NPM Scripts state:
preinstall: Run BEFORE the package is installed
But does this occur before or after dependencies are downloaded?
That is, which of these is correct:
or
I couldn't see this covered by the npm script docs, but it's possible it's documented elsewhere.
I have also searched for the answer to this question and haven't found any documentation outlining the exact process.
However, from testing, it seems to depend. If you run npm link
or npm install
within a package directory, it will download dependencies and run scripts, but in this order:
Therefore, if your preinstall script uses dependencies, it will fail.
But if you run npm install <package>
or npm install <path/to/local/folder>
from another folder, it will do it in this order: