Repository: nvm-sh/nvm
File: nvm.sh (Shell)

Code before:
        local line
        while IFS=" " read -r -a line; do

          # Skip empty lines.
          [ -z "${line}" ] || continue

          # Skip comment lines that begin with `#`.
          [ "${line:0:1}" != "#" ] || continue

          # Fail on lines that have multiple space-separated words
          case ${VAR} in
            *\ * )
              nvm_echo "Only one package per line is allowed in the ${NVM_DIR}/default-packages file. Please remove any lines with multiple space-seperated values."
              return 1
            ;;
          esac

          DEFAULT_PACKAGES="${DEFAULT_PACKAGES}${line} "
        done < "${NVM_DIR}/default-packages"

        if [ -z "$DEFAULT_PACKAGES" ]; then
          nvm_echo "Installing default global packages from ${NVM_DIR}/default-packages..."
          { 
            nvm_echo "$DEFAULT_PACKAGES" | command xargs npm install -g --quiet 
          } || {
            nvm_echo "Failed installing default packages. Please check if your default-packages file or a package in it has problems!"
            return 1
          }
        fi
      fi

      if [ -n "${PROVIDED_REINSTALL_PACKAGES_FROM-}" ] && [ "$(nvm_ensure_version_prefix "${PROVIDED_REINSTALL_PACKAGES_FROM}")" = "${VERSION}" ]; then
        nvm_err "You can't reinstall global packages from the same version of node you're installing."
        return 4
      elif [ "${REINSTALL_PACKAGES_FROM-}" = 'N/A' ]; then
        nvm_err "If --reinstall-packages-from is provided, it must point to an installed version of node."
        return 5
      fi

      local FLAVOR
      if nvm_is_iojs_version "$VERSION"; then
        FLAVOR="$(nvm_iojs_prefix)"
      else
        FLAVOR="$(nvm_node_prefix)"
      fi

      if nvm_is_version_installed "$VERSION"; then
        nvm_err "$VERSION is already installed."
        if nvm use "$VERSION" && [ ! -z "$REINSTALL_PACKAGES_FROM" ] && [ "_$REINSTALL_PACKAGES_FROM" != "_N/A" ]; then
          nvm reinstall-packages "$REINSTALL_PACKAGES_FROM"
        fi

Review comment (suggestion):
this is error output; it should use `nvm_err` instead of `nvm_echo`

Code after:
          ;;
          --skip-default-packages)
            SKIP_DEFAULT_PACKAGES=true
          ;;
          *)
            ADDITIONAL_PARAMETERS="$ADDITIONAL_PARAMETERS $1"
          ;;
        esac
        shift
      done

      if [ -z "$SKIP_DEFAULT_PACKAGES" ] && [ -f "${NVM_DIR}/default-packages" ]; then
        DEFAULT_PACKAGES=""

        # Read lines from $NVM_DIR/default-packages
        local line
        while IFS=" " read -r line; do
          # Skip empty lines.
          [ -n "${line}" ] || continue

          # Skip comment lines that begin with `#`.
          [ "$(echo "$line" | cut -c1)" != "#" ] || continue

          # Fail on lines that have multiple space-separated words
          case ${line} in
            *\ * )
              nvm_err "Only one package per line is allowed in the ${NVM_DIR}/default-packages file. Please remove any lines with multiple space-seperated values."
              return 1
            ;;
          esac

          DEFAULT_PACKAGES="${DEFAULT_PACKAGES}${line} "
        done < "${NVM_DIR}/default-packages"
      fi

      if [ -n "${PROVIDED_REINSTALL_PACKAGES_FROM-}" ] && [ "$(nvm_ensure_version_prefix "${PROVIDED_REINSTALL_PACKAGES_FROM}")" = "${VERSION}" ]; then
        nvm_err "You can't reinstall global packages from the same version of node you're installing."
        return 4
      elif [ "${REINSTALL_PACKAGES_FROM-}" = 'N/A' ]; then
        nvm_err "If --reinstall-packages-from is provided, it must point to an installed version of node."
        return 5
      fi

      local FLAVOR
      if nvm_is_iojs_version "$VERSION"; then
        FLAVOR="$(nvm_iojs_prefix)"
      else
        FLAVOR="$(nvm_node_prefix)"
      fi

      if nvm_is_version_installed "$VERSION"; then