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

Module imports not working #367

Open
akashKarmakar02 opened this issue Jul 9, 2024 · 5 comments
Open

Module imports not working #367

akashKarmakar02 opened this issue Jul 9, 2024 · 5 comments

Comments

@akashKarmakar02
Copy link

In Javet i want to use module import but it is saying no module found but when i use require it pick the correct package from node_modules

@caoccao
Copy link
Owner

caoccao commented Jul 9, 2024

Please review the doc.

@akashKarmakar02
Copy link
Author

akashKarmakar02 commented Jul 9, 2024

var node = NodeJsRunTimeProvider.getRuntime();
node.getNodeModule(NodeModuleModule.class).setRequireRootDirectory(new File(JavetOSUtils.WORKING_DIRECTORY));
node.setV8ModuleResolver(new JavetBuiltInModuleResolver());
System.out.println(JavetOSUtils.WORKING_DIRECTORY);
node.getExecutor(output.getCode()).setModule(true).executeVoid();```



What am i doing wrong.

@caoccao
Copy link
Owner

caoccao commented Jul 9, 2024

require() doesn't involve the module resolver. Please read the doc.

@akashKarmakar02
Copy link
Author

i am using import React from "react" it is failing saying module not found but. const React = require("react") works

@caoccao
Copy link
Owner

caoccao commented Jul 9, 2024

READ THE DOC.

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

2 participants