npm: disable postinstall script for package

2019-01-30 17:06发布

Is it any npm option exist to disable postinstall script while installing package? Or for rewriting any field from package.json?

标签: node.js npm
2条回答
劫难
2楼-- · 2019-01-30 17:23

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
查看更多
唯我独甜
3楼-- · 2019-01-30 17:45

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.

查看更多
登录 后发表回答