Skip to content
Taritsyn edited this page Mar 11, 2020 · 16 revisions

JavaScriptEngineSwitcher.Node contains adapter NodeJsEngine (wrapper for the Jering.Javascript.NodeJS version 5.4.0).

This package does not contain the node.exe. Therefore, you need to install the Node.js and add the node.exe's directory to the Path environment variable (automatically done by the official installer).

Engine settings

You can specify a settings of JS engine during its registration:

engineSwitcher.EngineFactories
	.AddNode(new NodeSettings
	{
		TimeoutInterval = TimeSpan.FromMilliseconds(600),
		UseBuiltinLibrary = true
	})
	;

If you manually create an instance of JS engine, then you can pass settings via the constructor:

IJsEngine engine = new NodeJsEngine(
	new NodeSettings
	{
		TimeoutInterval = TimeSpan.FromMilliseconds(600),
		UseBuiltinLibrary = true
	}
);

Consider in detail properties of the NodeSettings class:

Property name Data type Default value Description
TimeoutInterval TimeSpan TimeSpan.Zero

Interval to wait before the script execution times out.

UseBuiltinLibrary Boolean false

Flag for whether to use the Node.js built-in library (e.g. require function, process object, etc.).

Known issues

Since this module is not based on JS engine, but on runtime, then it does not fully comply with requirements of the JavaScript Engine Switcher:

  1. Not supported undefined type.
  2. There is no full support of null.
  3. Non-generic versions of the Evaluate, CallFunction and GetVariableValue methods are not supported.
  4. EmbedHostObject and EmbedHostType methods, that responsible for interop, is also not supported.