Is it any npm option exist to disable postinstall script while installing package? Or for rewriting any field from package.json?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
It's not possible to disable only postinstall
scripts. However, you can disable all scripts using:
$ npm install --ignore-scripts
As delbertooo mentionned in the comments, this also disables the scripts of the dependencies.
回答2:
To do this for your own library, I recommend something simple like:
#!/usr/bin/env bash
## this is your postinstall.sh script:
set -e;
if [ "$your_pkg_skip_postinstall" == "yes" ]; then
echo "skipping your package's postinstall routine.";
exit 0;
fi
then do your npm install with:
your_pkg_skip_postinstall="yes" npm install