Based on your shared output, are you instead running xk6 build --with github.com/grafana/xk6-output-influxdb? Locally running this also worked in my case.
$ xk6 build --with github.com/grafana/xk6-output-influxdb
2023/06/20 10:25:20 [INFO] Temporary folder: /xk6-output-influxdb/buildenv_2023-06-20-1025.1609116281
2023/06/20 10:25:20 [INFO] Initializing Go module
2023/06/20 10:25:20 [INFO] exec (timeout=10s): /usr/local/go/bin/go mod init k6
go: creating new go.mod: module k6
2023/06/20 10:25:21 [INFO] Pinning versions
2023/06/20 10:25:21 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod edit -require github.com/grafana/xk6-output-influxdb@latest
2023/06/20 10:25:21 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17
go: downloading github.com/grafana/xk6-output-influxdb v0.4.0
2023/06/20 10:25:22 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17
2023/06/20 10:25:22 [INFO] Writing main module: /xk6-output-influxdb/buildenv_2023-06-20-1025.1609116281/main.go
2023/06/20 10:25:22 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17
2023/06/20 10:25:22 [INFO] Build environment ready
2023/06/20 10:25:22 [INFO] Building k6
2023/06/20 10:25:22 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17
2023/06/20 10:25:22 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /xk6-output-influxdb/k6 -ldflags=-w -s -trimpath
2023/06/20 10:25:45 [INFO] Build complete: ./k6
2023/06/20 10:25:45 [INFO] Cleaning up temporary folder: /xk6-output-influxdb/buildenv_2023-06-20-1025.1609116281
xk6 has now produced a new k6 binary which may be different than the command on your system path!
$ ./k6 version
k6 v0.43.1 ((devel), go1.19.3, darwin/amd64)
Extensions:
github.com/grafana/xk6-output-influxdb v0.4.0, xk6-influxdb [output]
We can better help if we know where it fails for you, building the dockerfile, or creating the k6 binary with the extension. If the latter, I would check the prerequisites. Or better use k6’s guide to build a k6 binary using Docker.