-
Currently I am just trying to import a basic math script that has a add function. // file: math.js
const add = (a, b) => { return a + b }
module.exports = {
add
} then in another file I am trying to import it. each way of importing it was ran independently* const math = require("./math.js")
print(math.add(4, 6))
// result: Jint.Runtime.JavaScriptException: require is not defined
import { add } from "./math.js"
print(add(4, 6))
// result: Esprima.ParserException: Line 4: Unexpected token
const math = import("./math.js")
print(math.add(4, 6))
// result: System.UriFormatException: Invalid URI: The URI is empty. Forgive me if this has been asked before but I did look and couldn't find anything that best fit nor did I find any real answers |
Beta Was this translation helpful? Give feedback.
Answered by
lahma
Oct 27, 2023
Replies: 1 comment 2 replies
-
I'd generally guide towards the sample in main readme and the test suite showing different ways to handle module code. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Generally you need to be in module context when importing modules, Evaluate and Execute are not.
If you've enabled modules with base path importing relative should work. You can override settings via engine's module options which allows also customizing loading logic.