Is it possible to run a .net library inside nodejs? - node.js

I need to run the system.data.sqlite library which is a .net library that creates a password in the sqlite database, and for me to be able to read this database in nodejs I need to install this library. It's possible? If so how can I do this?

Your simplest option may be to create a stand-alone .NET program using the desired .NET library that does what you want. This stand-alone program can work off either command line arguments or environment variables or stdin depending what you need to send to the program in order to do its thing.
You can then run that stand-alone program from within nodejs using the child_process module. You can pass it arguments or retrieve results if necessary.

Related

How to update the PATH variable in a platform agnostic way using node js

i am making a CLI to automate the installation process of a software. I install it in a directory like $HOME/.software-name/. Now i would like to know about a platfrom agnostic way to update the system PATH environment variable so that in the future the user can run the command easily.
I am not looking for a os specific way like setx on windows or writing to the ~/.bashrc. I would prefer a library to do the task or a builtin function.
i know that i can retrieve the env variable using process.env.variableName but setting it would not work outside the child process (ie, NodeJS). It does work inside the NodeJS process but that is obviously not what is wanted here.
Thanks :)

Using Insall4j for a simple server (with no java)

Is there any way I can ignore all the java components that Install4J uses? For example not requiring the user to have java installed? I have a very simple executable that I would like the user to install onto their machine and I would like the user to be able to enter some input for things like port.
The issue is that Install4J requires you to have java downloaded, and it also installs a ton of unnessary items that I don't need for this project.
Reason I'm using Install4J is my company has a license for it, and its very clean and easy to use unlike something like Inno where its windows only and I would need to learn how to script it.
The project is a javascript nodejs file thats already been packaged. I just need a neat installer so that all the client needs to do is enter some information such as port and have the program read the xml file for the needed input.
Thanks.
EDIT: Seems to not be possible. See: Can you use nodejs with install4j

Using Node.dll binary to execute JS in Win32

As the title says, I would like to run a JS file from within my application. I dont want to create a node.exe process. Is there any sample example to start with?
Edit:
I plan to use standalone dll that comes with electron installer - https://www.npmjs.com/package/electron-installer-windows
or build it myself using electron instructions
If you just need run JavaScript in a Windows app, you can use ActiveScript instead.
Otherwise this doesn't seem like a programming question.

How to run ElectronJs without a UI?

As well as a UI, I'd like users to have the option of passing in command line options to my tool and for it to output the response to the command line (eg manually or in cron).
Even without creating a window, the UI gets going (eg taskbar on the mac), and on a linux back-end server with no UI libraries it crashes completely.
Is there a way I can avoid having to ship two apps separately, and also more annoyingly using electron to package up one exe, and something like pkg for the other?
Thanks!
You can use a bundling tool like EncloseJS to wrap your Electron application. This would allow you to write a CLI interface. You would then need to move the code that does the actual work to a shared library that both Electron and your CLI can use. You could then introduce a --headless flag that would simply not start the Electron app, while omitting the flag would start the app as usual.

How can I (literally) open a file with Node?

I'm creating a command-line utility with Node that will be able to open (launch) files for the user programmatically, using the application they would use to do so by default.
After reading through the docs, I don't think fs.open() can do that.
Is there any way to do this in Node without having to pull in shell scripts?
You'd need to call a special OS-dependent program via child_process.exec() or child_process.spawn(). On Windows you'd use start, for OSX you'd use open, and for Linux you'd generally use xdg-open. You might look at using an already made module on npm for handling all these cases, such as open.

Resources