grafana/k6 · error
external module names must be prefixed with
Error message
external module names must be prefixed with '%s', tried to register: %s
What it means
Register was called with an external module name lacking the mandatory 'k6/x/' prefix. This is a compile-time-style guard for extension authors (xk6 builds): Register panics rather than returning an error, because a mis-prefixed module would be silently unimportable from scripts.
Solutions
- Prefix the module name with 'k6/x/', e.g. Register('k6/x/myextension', mod)
- Check the name for typos before the k6/x/ prefix
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at js/modules/modules.go:23 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/3d0255dc30572409.
Report an issue: GitHub.
Appendix: source
Thrown at js/modules/modules.go:23
"context"
"fmt"
"strings"
"github.com/grafana/sobek"
"go.k6.io/k6/v2/ext"
"go.k6.io/k6/v2/js/common"
"go.k6.io/k6/v2/lib"
)
const extPrefix string = "k6/x/"
// Register the given mod as an external JavaScript module that can be imported
// by name. The name must be unique across all registered modules and must be
// prefixed with "k6/x/", otherwise this function will panic.
func Register(name string, mod any) {
if !strings.HasPrefix(name, extPrefix) {
panic(fmt.Errorf("external module names must be prefixed with '%s', tried to register: %s", extPrefix, name))
}
ext.Register(name, ext.JSExtension, mod)
}
// Module is the interface js modules should implement in order to get access to the VU
type Module interface {
// NewModuleInstance will get modules.VU that should provide the module with a way to interact with the VU.
// This method will be called for *each* VU that imports the module *once* per that VU.
NewModuleInstance(VU) Instance
}
// Instance is what a module needs to return
type Instance interface {
Exports() Exports
}
// VU gives access to the currently executing VU to a module InstanceView on GitHub (pinned to 01ffac6f24)