Shopify CLI gives an Error while using it to create an extension!

Try changing shopify-cli\lib\project_types\extension\commands\serve.rb from:

def find_available_port(runtime_configuration)
        return runtime_configuration unless specification_handler.choose_port?(@ctx)

        chosen_port = Tasks::ChooseNextAvailablePort
          .call(from: runtime_configuration.port)
          .unwrap { |_error| @ctx.abort(@ctx.message("serve.no_available_ports_found")) }
        runtime_configuration.tap { |c| c.port = chosen_port }
      end

to:

def find_available_port(runtime_configuration)
        puts "Hack fix is in place."
        return runtime_configuration
      end