{"id":1594,"date":"2019-06-08T15:11:21","date_gmt":"2019-06-08T09:41:21","guid":{"rendered":"https:\/\/www.rangakrish.com\/?p=1594"},"modified":"2019-06-08T15:16:48","modified_gmt":"2019-06-08T09:46:48","slug":"using-nodejs-in-mathematica-12","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/08\/using-nodejs-in-mathematica-12\/","title":{"rendered":"Using NodeJS in Mathematica 12"},"content":{"rendered":"<p>In an earlier <a href=\"https:\/\/www.rangakrish.com\/index.php\/2019\/05\/05\/python-integration-in-mathematica-12\/\" target=\"_blank\" rel=\"noopener\"><em><strong>article<\/strong><\/em><\/a>, I had described <em><strong>Python<\/strong><\/em> integration in <em><strong>Mathematica 12<\/strong><\/em>. In addition to <em><strong>Python<\/strong><\/em>, <em><strong>NodeJS<\/strong><\/em> is also supported as a default <em><strong>\u201cexternal\u201d<\/strong> <\/em>language. In today\u2019s article, I will focus on <em><strong>NodeJS<\/strong><\/em> integration. By the way, <em><strong>NodeJS<\/strong><\/em> support was introduced in <em><strong>Mathematica 11.2<\/strong><\/em>.<\/p>\n<p>Before using <em><strong>NodeJS<\/strong><\/em> with <em><strong>Mathematica 12<\/strong><\/em>, the system must be configured appropriately. The steps are clearly explained <a href=\"https:\/\/reference.wolfram.com\/language\/workflow\/ConfigureNodeJSForExternalEvaluate.html\" target=\"_blank\" rel=\"noopener\"><em><strong>here<\/strong><\/em><\/a>.\u00a0It is quite simple and straightforward.<\/p>\n<p>To confirm that <em><strong>Mathematica<\/strong><\/em> can now interact with <em><strong>NodeJS<\/strong><\/em>, run the following command:<\/p>\n<figure id=\"attachment_1595\" aria-describedby=\"caption-attachment-1595\" style=\"width: 648px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/FindExternalEvaluators.png?ssl=1\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" data-attachment-id=\"1595\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/08\/using-nodejs-in-mathematica-12\/findexternalevaluators-2\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/FindExternalEvaluators.png\" data-orig-size=\"775,110\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"FindExternalEvaluators Function\" data-image-description=\"&lt;p&gt;FindExternalEvaluators Function&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;FindExternalEvaluators Function&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/FindExternalEvaluators.png\" class=\"wp-image-1595\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/FindExternalEvaluators.png?resize=648%2C92&#038;ssl=1\" alt=\"FindExternalEvaluators Function\" width=\"648\" height=\"92\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/FindExternalEvaluators.png?w=775&amp;ssl=1 775w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/FindExternalEvaluators.png?resize=300%2C43&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/FindExternalEvaluators.png?resize=768%2C109&amp;ssl=1 768w\" sizes=\"(max-width: 648px) 100vw, 648px\" \/><\/a><figcaption id=\"caption-attachment-1595\" class=\"wp-caption-text\"><strong>FindExternalEvaluators Function<\/strong><\/figcaption><\/figure>\n<p>The response shows that everything is in order.<\/p>\n<h2>Using NodeJS Cell<\/h2>\n<p>Let us begin with the <em><strong>NodeJS<\/strong><\/em> cell. Type <strong>\u201c&gt;\u201d<\/strong> in the Mathematica notebook and it converts the current cell into <em><strong>Python<\/strong><\/em> cell.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<figure id=\"attachment_1596\" aria-describedby=\"caption-attachment-1596\" style=\"width: 654px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Python-Cell.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"1596\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/08\/using-nodejs-in-mathematica-12\/python-cell-2\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Python-Cell.png\" data-orig-size=\"743,67\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Python Cell\" data-image-description=\"&lt;p&gt;Python Cell&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Python Cell&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Python-Cell.png\" class=\"wp-image-1596\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Python-Cell.png?resize=654%2C59&#038;ssl=1\" alt=\"Python Cell\" width=\"654\" height=\"59\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Python-Cell.png?w=743&amp;ssl=1 743w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Python-Cell.png?resize=300%2C27&amp;ssl=1 300w\" sizes=\"(max-width: 654px) 100vw, 654px\" \/><\/a><figcaption id=\"caption-attachment-1596\" class=\"wp-caption-text\"><strong>Python Cell<\/strong><\/figcaption><\/figure>\n<p>To convert this into a <em><strong>NodeJS<\/strong><\/em> cell, left-click on the <em><strong>Python<\/strong><\/em> symbol and then select <em><strong>NodeJS<\/strong><\/em> option.<\/p>\n<figure id=\"attachment_1597\" aria-describedby=\"caption-attachment-1597\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Selecting-NodeJS.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"1597\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/08\/using-nodejs-in-mathematica-12\/selecting-nodejs\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Selecting-NodeJS.png\" data-orig-size=\"774,92\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Selecting NodeJS Cell Type\" data-image-description=\"&lt;p&gt;Selecting NodeJS Cell Type&lt;\/p&gt;\n\" data-image-caption=\"\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Selecting-NodeJS.png\" class=\"wp-image-1597\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Selecting-NodeJS.png?resize=650%2C77&#038;ssl=1\" alt=\"Selecting NodeJS Cell Type\" width=\"650\" height=\"77\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Selecting-NodeJS.png?w=774&amp;ssl=1 774w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Selecting-NodeJS.png?resize=300%2C36&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Selecting-NodeJS.png?resize=768%2C91&amp;ssl=1 768w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><figcaption id=\"caption-attachment-1597\" class=\"wp-caption-text\"><strong>Selecting NodeJS Cell Type<\/strong><\/figcaption><\/figure>\n<p>Now you can enter <em><strong>NodeJS<\/strong><\/em> expressions and evaluate them.<\/p>\n<figure id=\"attachment_1598\" aria-describedby=\"caption-attachment-1598\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Cell1.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1598\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/08\/using-nodejs-in-mathematica-12\/cell1\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Cell1.png\" data-orig-size=\"782,88\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"NodeJS Expression\" data-image-description=\"&lt;p&gt;NodeJS Expression&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;NodeJS Expression&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Cell1.png\" class=\"wp-image-1598\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Cell1.png?resize=650%2C73&#038;ssl=1\" alt=\"NodeJS Expression\" width=\"650\" height=\"73\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Cell1.png?w=782&amp;ssl=1 782w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Cell1.png?resize=300%2C34&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Cell1.png?resize=768%2C86&amp;ssl=1 768w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><figcaption id=\"caption-attachment-1598\" class=\"wp-caption-text\"><strong>NodeJS Expression<\/strong><\/figcaption><\/figure>\n<p>Here is some more:<\/p>\n<figure id=\"attachment_1599\" aria-describedby=\"caption-attachment-1599\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Cell2.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1599\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/08\/using-nodejs-in-mathematica-12\/cell2\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Cell2.png\" data-orig-size=\"782,156\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"NodeJS Expression\" data-image-description=\"&lt;p&gt;NodeJS Expression&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;NodeJS Expression&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Cell2.png\" class=\"wp-image-1599\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Cell2.png?resize=650%2C130&#038;ssl=1\" alt=\"NodeJS Expression\" width=\"650\" height=\"130\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Cell2.png?w=782&amp;ssl=1 782w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Cell2.png?resize=300%2C60&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Cell2.png?resize=768%2C153&amp;ssl=1 768w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><figcaption id=\"caption-attachment-1599\" class=\"wp-caption-text\"><strong>NodeJS Expression<\/strong><\/figcaption><\/figure>\n<h2>Using ExternalEvaluate[]<\/h2>\n<p>The other option is to use <em><strong>\u201cExternalEvaluate[]\u201d<\/strong><\/em> as follows:<\/p>\n<figure id=\"attachment_1600\" aria-describedby=\"caption-attachment-1600\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/ExternalEvaluate.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1600\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/08\/using-nodejs-in-mathematica-12\/externalevaluate\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/ExternalEvaluate.png\" data-orig-size=\"778,128\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"ExternalEvaluate Function\" data-image-description=\"&lt;p&gt;ExternalEvaluate Function&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;ExternalEvaluate Function&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/ExternalEvaluate.png\" class=\"wp-image-1600\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/ExternalEvaluate.png?resize=650%2C107&#038;ssl=1\" alt=\"ExternalEvaluate Function\" width=\"650\" height=\"107\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/ExternalEvaluate.png?w=778&amp;ssl=1 778w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/ExternalEvaluate.png?resize=300%2C49&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/ExternalEvaluate.png?resize=768%2C126&amp;ssl=1 768w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><figcaption id=\"caption-attachment-1600\" class=\"wp-caption-text\"><strong>ExternalEvaluate Function<\/strong><\/figcaption><\/figure>\n<p>The first argument denotes the language to use, in this case, <em><strong>\u201cNodeJS\u201d<\/strong><\/em>. Keep in mind that each call to <em><strong>ExternalEvaluate[]<\/strong><\/em> is evaluated in the context of a temporary <em><strong>NodeJS<\/strong><\/em> session.<\/p>\n<h2>Explicit NodeJS Session<\/h2>\n<p>Often times, it is convenient to create an explicit <em><strong>NodeJS<\/strong><\/em> session and evaluate expressions in that session, finally terminating the session when no more needed.<\/p>\n<figure id=\"attachment_1601\" aria-describedby=\"caption-attachment-1601\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Session1.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1601\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/08\/using-nodejs-in-mathematica-12\/session1\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Session1.png\" data-orig-size=\"777,239\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Explicit NodeJS Session\" data-image-description=\"&lt;p&gt;Explicit NodeJS Session&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Explicit NodeJS Session&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Session1.png\" class=\"wp-image-1601\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Session1.png?resize=650%2C200&#038;ssl=1\" alt=\"Explicit NodeJS Session\" width=\"650\" height=\"200\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Session1.png?w=777&amp;ssl=1 777w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Session1.png?resize=300%2C92&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Session1.png?resize=768%2C236&amp;ssl=1 768w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><figcaption id=\"caption-attachment-1601\" class=\"wp-caption-text\"><strong>Explicit NodeJS Session<\/strong><\/figcaption><\/figure>\n<p>We can also load a <em><strong>NodeJS<\/strong><\/em> file and use any function from that file.<\/p>\n<figure id=\"attachment_1602\" aria-describedby=\"caption-attachment-1602\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Session2.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1602\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/08\/using-nodejs-in-mathematica-12\/session2\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Session2.png\" data-orig-size=\"776,318\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"NodeJS Session Continued\" data-image-description=\"&lt;p&gt;NodeJS Session Continued&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;NodeJS Session Continued&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Session2.png\" class=\"wp-image-1602\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Session2.png?resize=650%2C266&#038;ssl=1\" alt=\"NodeJS Session Continued\" width=\"650\" height=\"266\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Session2.png?w=776&amp;ssl=1 776w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Session2.png?resize=300%2C123&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Session2.png?resize=768%2C315&amp;ssl=1 768w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><figcaption id=\"caption-attachment-1602\" class=\"wp-caption-text\"><strong>NodeJS Session Continued<\/strong><\/figcaption><\/figure>\n<p>We are ready to close the session at this point.<\/p>\n<figure id=\"attachment_1603\" aria-describedby=\"caption-attachment-1603\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Close-Session.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1603\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/08\/using-nodejs-in-mathematica-12\/close-session\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Close-Session.png\" data-orig-size=\"780,43\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Closing the Session\" data-image-description=\"&lt;p&gt;Closing the Session&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Closing the Session&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Close-Session.png\" class=\"wp-image-1603\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Close-Session.png?resize=650%2C36&#038;ssl=1\" alt=\"Closing the Session\" width=\"650\" height=\"36\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Close-Session.png?w=780&amp;ssl=1 780w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Close-Session.png?resize=300%2C17&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Close-Session.png?resize=768%2C42&amp;ssl=1 768w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><figcaption id=\"caption-attachment-1603\" class=\"wp-caption-text\"><strong>Closing the Session<\/strong><\/figcaption><\/figure>\n<p>Support for <em><strong>NodeJS<\/strong><\/em> appears to be quite mature. It will come in handy when we use <em><strong>Mathematica<\/strong><\/em> to communicate with external channels that support <em><strong>NodeJS<\/strong><\/em>.<\/p>\n<p>This concludes today\u2019s discussion on using <em><strong>NodeJS<\/strong><\/em> in <em><strong>Mathematica<\/strong><\/em>. Feel free to download my <em><strong>Mathematica<\/strong> <a href=\"http:\/\/www.rangakrish.com\/downloads\/NodeJS.nb\" target=\"_blank\" rel=\"noopener\"><strong>notebook<\/strong><\/a><\/em>\u00a0and <em><strong>NodeJS<\/strong> <a href=\"http:\/\/www.rangakrish.com\/downloads\/Example.js\" target=\"_blank\" rel=\"noopener\"><strong>file<\/strong><\/a><\/em>.<\/p>\n<p>Have a nice weekend!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In an earlier article, I had described Python integration in Mathematica 12. In addition to Python, NodeJS is also supported as a default \u201cexternal\u201d language. In today\u2019s article, I will focus on NodeJS integration. By the way, NodeJS support was introduced in Mathematica 11.2. Before using NodeJS with Mathematica 12, the system must be configured [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[72,17],"tags":[206,210],"class_list":["post-1594","post","type-post","status-publish","format-standard","hentry","category-mathematica","category-programming","tag-mathematica-12","tag-nodejs"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-pI","jetpack-related-posts":[{"id":1560,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/05\/05\/python-integration-in-mathematica-12\/","url_meta":{"origin":1594,"position":0},"title":"Python Integration in Mathematica 12","author":"admin","date":"May 5, 2019","format":false,"excerpt":"Mathematica has had Python support since ver 11.2 through ExternalEvaluate[]. In ver 11.3 it was possible to input Python expression in a cell by beginning with \u201c>\u201d character. The good news is that Mathematica 12 has significantly enhanced this integration. Python Cells Let us start with the simplest way to\u2026","rel":"","context":"In &quot;Mathematica&quot;","block_context":{"text":"Mathematica","link":"https:\/\/www.rangakrish.com\/index.php\/category\/mathematica\/"},"img":{"alt_text":"Function References","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/05\/External-Evaluate-4.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/05\/External-Evaluate-4.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/05\/External-Evaluate-4.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":2947,"url":"https:\/\/www.rangakrish.com\/index.php\/2022\/11\/24\/using-julia-from-mathematica\/","url_meta":{"origin":1594,"position":1},"title":"Using Julia from Mathematica","author":"admin","date":"November 24, 2022","format":false,"excerpt":"In an earlier article, I had shown how it is possible to interact with Mathematica from Julia. In today\u2019s article, I will share the details of how to interact with Julia from within Mathematica. Why would somebody want to execute Julia code inside Mathematica? Although Mathematica is a great symbolic\u2026","rel":"","context":"In &quot;Julia&quot;","block_context":{"text":"Julia","link":"https:\/\/www.rangakrish.com\/index.php\/category\/julia\/"},"img":{"alt_text":"Installing Julia","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/11\/Julia-Shell.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/11\/Julia-Shell.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2022\/11\/Julia-Shell.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3381,"url":"https:\/\/www.rangakrish.com\/index.php\/2024\/05\/20\/using-openai-from-mathematica\/","url_meta":{"origin":1594,"position":2},"title":"Using OpenAI from Mathematica","author":"admin","date":"May 20, 2024","format":false,"excerpt":"Mathematica was among the first to integrate with OpenAI. The functionality is nicely exposed in terms of a few pre-defined functions. Let us explore some of the functionality in today\u2019s article. The simplest way to get started is to use LLMSynthesize\u00a0function: It can take a few seconds before you get\u2026","rel":"","context":"In &quot;Mathematica&quot;","block_context":{"text":"Mathematica","link":"https:\/\/www.rangakrish.com\/index.php\/category\/mathematica\/"},"img":{"alt_text":"LLMSynthesize Function","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/05\/Example1-300x27.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/05\/Example1-300x27.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/05\/Example1-300x27.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3626,"url":"https:\/\/www.rangakrish.com\/index.php\/2025\/02\/21\/using-openai-from-mathematica-part-3\/","url_meta":{"origin":1594,"position":3},"title":"Using OpenAI from Mathematica: Part-3","author":"admin","date":"February 21, 2025","format":false,"excerpt":"Let us continue our discussion on using Mathematica to interact with OpenAI (you may want to go through the earlier article as well). The simplest function to interact with the LLM is LLMSynthesize[]. As you might have guessed, this is a \u201csync\u201d (non-streaming) call. What if you expect a long\u2026","rel":"","context":"In &quot;Mathematica&quot;","block_context":{"text":"Mathematica","link":"https:\/\/www.rangakrish.com\/index.php\/category\/mathematica\/"},"img":{"alt_text":"Basic LLMSynthesize","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/02\/fig1-300x21.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/02\/fig1-300x21.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2025\/02\/fig1-300x21.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":285,"url":"https:\/\/www.rangakrish.com\/index.php\/2016\/07\/22\/using-julia-to-interact-with-mathematica\/","url_meta":{"origin":1594,"position":4},"title":"Using Julia to Interact with Mathematica","author":"admin","date":"July 22, 2016","format":false,"excerpt":"Mathematica is a powerful environment for symbolic and numerical computation. I have been using it for many years now. In this post\u00a0I had explained how we can use Mathematica bundled with Raspberry distribution to control littleBits devices. When I saw that there is support in Julia for interacting with Mathematica,\u2026","rel":"","context":"In &quot;Julia&quot;","block_context":{"text":"Julia","link":"https:\/\/www.rangakrish.com\/index.php\/category\/julia\/"},"img":{"alt_text":"Julia Session","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2016\/07\/Julia-1.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2016\/07\/Julia-1.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2016\/07\/Julia-1.png?resize=525%2C300 1.5x"},"classes":[]},{"id":3514,"url":"https:\/\/www.rangakrish.com\/index.php\/2024\/10\/02\/using-openai-from-mathematica-part-2\/","url_meta":{"origin":1594,"position":5},"title":"Using OpenAI from Mathematica: Part-2","author":"admin","date":"October 2, 2024","format":false,"excerpt":"I had written an earlier article\u00a0showing how to use OpenAI models from Mathematica ver 14.0.\u00a0 Wolfram Mathematica ver 14.1 was released recently, with several improvements in the area of LLMs. Of course, there are many other core additions as well, but our focus is on LLMs in this article. This\u2026","rel":"","context":"In &quot;Mathematica&quot;","block_context":{"text":"Mathematica","link":"https:\/\/www.rangakrish.com\/index.php\/category\/mathematica\/"},"img":{"alt_text":"LLMSynthesize Function","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/10\/image1-300x71.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/10\/image1-300x71.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/10\/image1-300x71.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/1594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/comments?post=1594"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/1594\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=1594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=1594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=1594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}