Reputation: 446
I am trying to make a test for npm packages for my project such that every time I try to install a module i.e run npm install <module>
a script must be run before that module is installed. The preinstall script only works with npm install
and not with npm install <module>
.
eg :- If run npm install request
. It should run a script which shows me all the dependencies of the request module before installing the module. Thanks in advance.
Upvotes: 23
Views: 18605
Reputation: 379
Add "install": "[Your Command]"
in the script part of your package.json
Example:
{
"name": "test",
"version": "1.0.0",
"description": "A sample test",
"main": "index.js",
"scripts": {
"install": "echo Test"
}
}
You can also use a pre hook with "preinstall": "[Your Command]"
Upvotes: 10