npm: disable postinstall script for package

前端 未结 4 1180
傲寒
傲寒 2020-12-07 13:35

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

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 14:09

    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
    

提交回复
热议问题