I am trying to retrieve the computer name from my computer so I can use it in comparison in my mysql query.
I would like to define computerName
as a variable that grabs the user-defined computer name using NodeJs
. This application is being run via electron for windows.
Any help would be greatly appreciated.
According to the node. js documentation for the "os" module you need to load the "os" module, which has a hostname() function: var os = require("os"); var hostname = os. hostname();
To see if Node is installed, open the Windows Command Prompt, Powershell or a similar command line tool, and type node -v . This should print a version number, so you'll see something like this v0. 10.35 .
Electron uses Chromium and Node.js so you can build your app with HTML, CSS, and JavaScript.
Electron. js is a runtime framework that allows the user to create desktop-suite applications with HTML5, CSS, and JavaScript. It's an open source project started by Cheng Zhao, an engineer at GitHub.
You can use the standard nodeJS os
API to retrieve the (host)name of a computer, see this API documentation for more details.
const computerName = os.hostname()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With