-
I came across #116 to enable package main
import (
"github.com/dop251/goja"
"github.com/dop251/goja_nodejs/console"
)
func main() {
runtime := goja.New()
console.Enable(runtime)
} returns (
but
does not seem to be valid Go (require.Require (value of type func(runtime *goja.Runtime, name string) goja.Value) is not a type). What can I do to load the console module? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The error message has not been updated after some refactoring. Should be fixed now. To clarify: it should be |
Beta Was this translation helpful? Give feedback.
-
@dop251 Thank you very much! This helped a lot. The following works for me now: package main
import (
"github.com/dop251/goja"
"github.com/dop251/goja_nodejs/console"
"github.com/dop251/goja_nodejs/require"
)
func main() {
runtime := goja.New()
new(require.Registry).Enable(runtime)
console.Enable(runtime)
runtime.RunString(`console.log("Hello");`)
} |
Beta Was this translation helpful? Give feedback.
The error message has not been updated after some refactoring. Should be fixed now.
To clarify: it should be
new(require.Registry).Enable(runtime)