Node.js

Is there a way to run Node.js from within a XOJO app? I am trying to run an external javascript file from within a XOJO app.

Hi. I have zero experience regarding JAVA within XOJO, but if we are talking about a Desktop App, this maybe helpfull: HTMLViewer.ExecuteJavaScript - Xojo Documentation

Thanks, But I tried that and the Javascript wont run for some reason using HTMLViewer.ExecuteJavaScript. It will run using Node.JS in terminal.

What is your code? What did you try? What doesn’t work? Do you get an error? Which OS? Which version of the OS? Which version of Xojo?

1 Like

You`re mixing things.

Javascript is executed in a browser, therefore you can execute JS in a HTMLViewer but it stays in its sandbox there and you have to find a way to get the result of your script out of the htmlviewer.

JS is also just the language, Node.JS uses. The both (frontend JS and Node.JS) have not so much in common.

Node.Js is a server side Javascript Framework, which has to be installed on the host system. Node uses the v8 JS engine to execute JS on OS level, without a browser. Node has access to the filesystem and a lot of other things are possible, which aren’t if you use JS in a browsers.

You can communicate to a Node.JS over two ways:

  1. Your Node app runs a webserver, for example Express, and you communicate over an RESTful API.
  2. You use a shell to run Node and execute shell commands with it.
3 Likes

I figured it out. I had to put the pathname to Node to get it to execute.
Thanks for your help.

1 Like
Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.