\fBtl;dr\fR Don\'t use \fBinstall\fR\|\. Use a \fB\|\.gyp\fR file for compilation, and \fBprepublish\fR for anything else\.
.
.P
You should almost never have to explicitly set a \fBpreinstall\fR or \fBinstall\fR script\. If you are doing this, please consider if there is
another option\.
.
.P
The only valid use of \fBinstall\fR or \fBpreinstall\fR scripts is for
compilation which must be done on the target architecture\. In early
versions of node, this was often done using the \fBnode\-waf\fR scripts, or
a standalone \fBMakefile\fR, and early versions of npm required that it be
explicitly set in package\.json\. This was not portable, and harder to
do properly\.
.
.P
In the current version of node, the standard way to do this is using a \fB\|\.gyp\fR file\. If you have a file with a \fB\|\.gyp\fR extension in the root
of your package, then npm will run the appropriate \fBnode\-gyp\fR commands
automatically at install time\. This is the only officially supported
method for compiling binary addons, and does not require that you add
anything to your package\.json file\.
.
.P
If you have to do other things before your package is used, in a way
that is not dependent on the operating system or architecture of the
target system, then use a \fBprepublish\fR script instead\. This includes
tasks such as:
.
.IP"\(bu"4
Compile CoffeeScript source code into JavaScript\.
.
.IP"\(bu"4
Create minified versions of JavaScript source code\.
.
.IP"\(bu"4
Fetching remote resources that your package will use\.
.
.IP""0
.
.P
The advantage of doing these things at \fBprepublish\fR time instead of \fBpreinstall\fR or \fBinstall\fR time is that they can be done once, in a
single place, and thus greatly reduce complexity and variability\.
Additionally, this means that:
.
.IP"\(bu"4
You can depend on \fBcoffee\-script\fR as a \fBdevDependency\fR, and thus
your users don\'t need to have it installed\.
.
.IP"\(bu"4
You don\'t need to include the minifiers in your package, reducing
the size for your users\.
.
.IP"\(bu"4
You don\'t need to rely on your users having \fBcurl\fR or \fBwget\fR or
The package\.json fields are tacked onto the \fBnpm_package_\fR prefix\. So,
for instance, if you had \fB{"name":"foo", "version":"1\.2\.5"}\fR in your
package\.json file, then your package scripts would have the \fBnpm_package_name\fR environment variable set to "foo", and the \fBnpm_package_version\fR set to "1\.2\.5"
Try not to use scripts to do what npm can do for you\. Read through npm help 5 \fBpackage\.json\fR to see all the things that you can specify and enable