Reputation: 99960
I have an NPM project, when npm install
is run, I'd like to run a custom script.
I tried using this in package.json:
"scripts": {
"ng": "ng",
"start": "ng serve",
"install": "./scripts/install.sh", // <<<<
},
but that actually just resulted in an infinite loop.
The reason I am looking for this, is because there are tools that simply call npm install
, so I can't control what they run. Otherwise, if I had control, I would just call ./scripts/install.sh
myself instead.
Note that this is probably not the best idea, just curious if it's possible.
Note my install script looks something like this:
#!/usr/bin/env bash
export FOO="bar";
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true";
npm install
Upvotes: 24
Views: 16812
Reputation: 3531
Use preinstall
to run code before npm install
. Don't try to override npm install
in this fashion where you would end up with an infinite loop of calls to npm install
.
You can also set environment variables using the config
property of package.json
. See docs for details
Upvotes: 28