How do I uninstall nodejs installed from pkg (Mac OS X)?

前端 未结 10 1934
别那么骄傲
别那么骄傲 2020-11-30 16:32

I installed NodeJS from pkg file on my Mac. Now I need to uninstall it. Tell me please how to do it. I tried to remove files from this list:

lsbom -f

10条回答
  •  遥遥无期
    2020-11-30 16:52

    A little convenience script expanding on previous answers.

    #!/bin/bash
    
    # Uninstall node.js
    # 
    # Options:
    #
    # -d Actually delete files, otherwise the script just _prints_ a command to delete.
    # -p Installation prefix. Default /usr/local
    # -f BOM file. Default /var/db/receipts/org.nodejs.pkg.bom
    
    CMD="echo sudo rm -fr"
    BOM_FILE="/var/db/receipts/org.nodejs.pkg.bom"
    PREFIX="/usr/local"
    
    while getopts "dp:f:" arg; do
        case $arg in
            d)
                CMD="sudo rm -fr"
                ;;
            p)
                PREFIX=$arg
                ;;
            f)
                BOM_FILE=$arg
                ;;
        esac
    done
    
    lsbom -f -l -s -pf ${BOM_FILE} \
        | while read i; do
              $CMD ${PREFIX}/${i}
          done
    
    $CMD ${PREFIX}/lib/node \
         ${PREFIX}/lib/node_modules \
         ${BOM_FILE}
    

    Save it to file and run with:

    # bash filename.sh
    

提交回复
热议问题