grafana/k6 · error
you are trying to access identifier
Error message
you are trying to access identifier %q, this likely is due to mixing ECMAScript Modules (ESM) and CommonJS syntax. This isn't supported in the JavaScript standard, please use only one or the other
What it means
Error "you are trying to access identifier %q, this likely is due to mixing ECMAScript Modules (ESM) and CommonJS syntax. This isn't supported in the JavaScript standard, please use only one or the other" thrown in grafana/k6.
Solutions
- Pick one module system for the whole script: use either import/export (ESM) or require/module.exports (CJS), not both
- Convert CommonJS require calls to ESM imports (or vice versa)
- Ensure files imported with ESM import syntax do not themselves use module.exports
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/js/bundle.go:509 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@3fcf5388d7 (2026-08-18).
Data as JSON: /api/errors/dc15eb74a4a0514d.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/bundle.go:511
logger := b.preInitState.Logger
if shouldWarn {
logger.Warningf("open() was used and is currently relative to '%s', but in the future "+
"it will be aligned with how `require` and imports work and will be relative to '%s'. This means "+
"that in the future open will open relative path relative to the module/file it is written in. "+
"You can future proof this by using `import.meta.resolve()` to get relative paths to the file it "+
"is written in the current k6 version.", pwd, otherPath)
err = b.preInitState.Usage.Uint64("deprecations/openRelativity", 1)
if err != nil {
logger.WithError(err).Warn("failed reporting usage of deprecated relativity of open()")
}
}
}
return openImpl(rt, b.filesystems["file"], pwd, filename, args...)
})
warnAboutModuleMixing := func(name string) {
warnFunc := rt.ToValue(func() error {
return fmt.Errorf(
"you are trying to access identifier %q, this likely is due to mixing "+
"ECMAScript Modules (ESM) and CommonJS syntax. "+
"This isn't supported in the JavaScript standard, please use only one or the other",
name)
})
err := rt.GlobalObject().DefineAccessorProperty(name, warnFunc, warnFunc, sobek.FLAG_FALSE, sobek.FLAG_FALSE)
if err != nil {
panic(fmt.Errorf("failed to set '%s' global object: %w", name, err))
}
}
warnAboutModuleMixing("module")
warnAboutModuleMixing("exports")
rt.SetFinalImportMeta(func(o *sobek.Object, mr sobek.ModuleRecord) {
err := o.Set("resolve", func(specifier string) (string, error) {
u, err := modSys.Resolve(mr, specifier)
if err != nil {
return "", errView on GitHub (pinned to 3fcf5388d7)