Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading error message when registry is not enabled #31

Closed
dop251 opened this issue Jul 12, 2022 · 0 comments
Closed

Misleading error message when registry is not enabled #31

dop251 opened this issue Jul 12, 2022 · 0 comments

Comments

@dop251
Copy link
Owner

dop251 commented Jul 12, 2022

Discussed in dop251/goja#404

Originally posted by pgundlach July 12, 2022
I came across dop251/goja#116 to enable console.log(), but when I use the command, I get an error

package main

import (
	"github.com/dop251/goja"
	"github.com/dop251/goja_nodejs/console"
)

func main() {
	runtime := goja.New()
	console.Enable(runtime)
}

returns (go run main.go)

go run main.go 
panic: TypeError: Please enable require for this runtime using new(require.Require).Enable(runtime)

goroutine 1 [running]:
github.com/dop251/goja_nodejs/require.Require(0x140001ba960?, {0x102737917, 0x7})
        /Users/patrick/go/pkg/mod/github.com/dop251/goja_nodejs@v0.0.0-20220706223936-8bb8eec2f26a/require/module.go:198 +0x144
github.com/dop251/goja_nodejs/console.Enable(0x14000198000?)
        /Users/patrick/go/pkg/mod/github.com/dop251/goja_nodejs@v0.0.0-20220706223936-8bb8eec2f26a/console/module.go:75 +0x30
main.main()
        /Users/patrick/prog/go/goja/main.go:10 +0x38
exit status 2

but

new(require.Require).Enable(runtime)

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?

@dop251 dop251 transferred this issue from dop251/goja Jul 12, 2022
@dop251 dop251 closed this as completed in 8cad205 Jul 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant