I am trying to run some policing script before any packages are installed. For Example:
{
"name": "pre-hook-check",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"preinstall": "echo preinstall",
"postinstall": "echo postinstall"
},
"author": "",
"license": "ISC",
"dependencies": {
"abc": "^0.6.1",
"preact": "^8.2.5"
}
}
It seems the pre and post install script on above example only works when I do npm install
, but I want that to run every time I try to install anything.
For example: Let's say I want to write a script to check for the version of the package any time my team runs npm install <some package>
. I want to check for the version of installing package and verify that it's version is above "1.0.0" else don't let them install.
I was planning to write a preinstall script that goes
npm info lodash version
and checks for the version of any package I am trying to install. If the version is not available, I plan to make it interactive and ask user's acknowledgement before install.