Install GopherJS in Go Modules Mode


Starting from Go 1.16, the module mode is on by default. You may heard that GOPATH is not needed in module mode, but if you want to install GopherJS, you still need to set it to build the GopherJS binary.

To install GopherJS, you need to set GOPATH environment variable first.

$ export GOPATH=/my/path/to/gopath

Then install GopherJS:

$ go get -u github.com/gopherjs/gopherjs

The executable GopherJS binary will be located in $(GOPATH)/bin, and remember to add this to your PATH variable.

Tested on: Ubuntu Linux 20.04, Go 1.17.1.


References:

[1]gopherjs: command not found · Issue #906 · gopherjs/gopherjs · GitHub