NodejsEnvironment.Import method
Imports a module or module property from JavaScript.
C#
public JSValue Import(string? module, string? property = null, bool esModule = false)
parameter | description |
---|---|
module | Name of the module being imported, or null to import a global property. This is equivalent to the value provided to import or require() in JavaScript. Required if property is null. |
property | Name of a property on the module (or global), or null to import the module object. Required if module is null. |
esModule | True if importing an ES module. The default is false. Note when importing an ES module the returned value will be a JS Promise object that resolves to the imported value. |
Return Value
The imported value.
Exceptions
exception | condition |
---|---|
ArgumentNullException | Both module and property are null. |
InvalidOperationException | The RequireFunction property was not initialized. |
See Also
- struct JSValue
- class NodejsEnvironment
- namespace Microsoft.JavaScript.NodeApi.Runtime