JS Windows. JavaScript Application for Windows

Table of contents:

JS Windows. JavaScript Application for Windows
JS Windows. JavaScript Application for Windows

Although Node is known as a server platform, interest in using it to build Windows desktop applications is growing rapidly. Bindings exist for GUI toolkits such as GTK+, QT, and Cocoa. However, one of the advantages of Node for web development is the ability to use the same language on both the server and the client. It functions well together with a web browser shell to develop cross-platform desktop applications and JS Windows games using WebGL with HTML, CSS and JS.

A brief history of the code

JavaScript has always been a programming language, or rather a script on the web. It was first introduced in 1995 and wasn't called JS Windows back then. During its early development, it was called Mocha, which was a pun on Java, the most popular programming language for web servers at the time. It was then changed to JavaScript in the Netscape Navigator web browser. Finally, it was later renamed to JavaScript with a very limited scope.

JavaScript in the Netscape Web BrowserNavigator
JavaScript in the Netscape Web BrowserNavigator

Thanks to the improvements made to the ECMAScript specification, JS has become the modern programming language for browsers. Thanks to its ubiquity and ubiquity, it has become one of the three pillars of the Internet along with HTML and CSS. However, the current level of IT usage requires running outside the browser.

Thus, in 2009, on the initiative of Ryan Dahl, Node was born - a free and open source JavaScript runtime that allows you to run JS outside of the browser as JS Windows. The written JS code runs on any OS that has Node installed, making the cross-platform aspect of the web accessible to everyone.

Operating principle

Operating principle
Operating principle

Node.js provides APIs that are not available in the browser environment. They have fewer restrictions. For example, the file system API is used to access and manipulate the OS. It provides the developer with the basic CRUD operations: create, read, update, and delete. For security reasons, this cannot be done in browsers. Essentially, JavaScript is becoming a more powerful and dangerous application.

There are times when the user needs to include external code in their own program. For example, when using jQuery, the removed tag is inserted, which imports the functionality of the application. The same goes for regular scripts that users write themselves. You can simply import any JS file with the removed tag. However, this can get cumbersome and have to manually manage hundreds ofdependencies.

In this case, Node.js comes to the rescue. How? Before installing Node JS on Windows or another OS, the user does not need to do any device upgrades, since the software provides an easy way to manage dependencies. It comes with a package manager (NPM). Through it, external data can be imported into user projects as dependencies.

Scope of packages:

  1. Servers.
  2. Database management.
  3. Web applications.
  4. Desktop and mobile apps.
  5. Robotics.


  1. Fast code execution.
  2. High scalability.
  3. Multifunctionality and asynchrony.
  4. No buffering.

Comparison: Node.js and JavaScript

Comparison: Node.js and JavaScript
Comparison: Node.js and JavaScript

Browsers have a built-in interpreter for JS. Node is both a framework for it and includes a set of libraries for using JS as a general-purpose programming language with an emphasis on asynchrony and non-blocking operations. In fact, the code runs the same interpreter as Google Chrome (V8), but provides a different set of libraries and a different runtime. It also includes a package management system (NPM) and several language extensions that browsers don't have, such as modules.

Thus, the JS interpreter in Google Chrome and the equivalent Windows JS application program in Node are essentially the same. The difference is that in the browserthe end goal is to change the content of a web page - text, graphics, stylesheets, and more, and in Js - running general purpose code that can do anything from activating a web server to manipulating files.

Desktop Utilities

Any existing web application is good enough to become one. It can be built from code that will benefit from being integrated into the user's system, from startup notifications to interacting with files and other desired programs. Some simply prefer to have certain applications permanently on their machine, available whether they have a connection or not.

Desktop Applications
Desktop Applications

It's easy to create powerful desktop utilities using web technologies like NW.js. Such programs have been around for a long time. In Shanghai in 2011, Roger Wang of the Intel Open Source Technology Center wrote node-webkit, a proof-of-concept module that allows the user to create a browser window and Node.

After some progress and transition from WebKit and Chromium, the open source software on which Google Chrome is based, Chen Zhao joined the project. Together they created an application runtime for Node and Chromium. The node-webkit project became quite popular and was later renamed to NW.js.

Downloading it, the user is actually running Chromium plus Node.js, as well as the application code itself. Not only does this mean that desktop software can be built usingHTML, CSS, and JavaScript, but it will also have access to all Node APIs, such as reading and writing to disk.

Both projects are built on top of Chromium and Node so you can write desktop applications using it at the system level and web technologies at the GUI level.

Technologies for the GUI layer
Technologies for the GUI layer

Electron has some advantages:

  1. More popular with developers.
  2. Has the best corporate support. Github and Microsoft are behind Electron, and NW.js is sponsored by Intel.
  3. Offers an automatic update mechanism out of the box.
  4. Building it is a bit easier because you don't have to combine all of Chromium.

NW.js benefits:

  1. Legacy support: Windows XP and older versions of Mac OS. Despite the fact that Microsoft has dropped support for XP, but many users still use it, so they really need this service.
  2. Application master entry can be either an HTML page or a Node.js file.
  3. It's more browser oriented.
  4. The approach to it is much simpler and clearer. This gives users many options.
  5. Separate and mixed contexts.
  6. It has a simple yet powerful mechanism regarding the JavaScript context, and "Electron" has two separate main and rendering contexts that are completely separated.
  7. Chrome extensions and Chrome API support. What's more, you can run Chrome apps and extensions with NW.js. "Electron"cannot and will not do so.
  8. Supports PDF files out of the box using Chrome's own PDF plugin.
  9. Has a source protection tool. This allows JavaScript to be compiled into V8 bytecode.
  10. Uses latest version of Chromium
  11. You can use the software without Dev Tools.
  12. Supports Chromium command line switches. For more information, please refer to the NW.js documentation. These switches can be used for performance tuning.
  13. The best security model for desktop applications. This is somewhat limited in Chrome (and web browsers in general) due to the nature of the user's relationship with websites. NW.js provides a different model that allows you to bypass all security restrictions such as sandboxing.

Getting started with the program

Getting started with the program
Getting started with the program

There are two versions of Node.js available for download. At the initial stage, it does not matter which one to choose. The Long Term Support version is considered the most stable. It is updated only when necessary for bug fixes and basic maintenance. This version is preferred in production environments and is much more stable. It is frequently updated with new features.

With a faster update cycle, the software has the most up-to-date APIs and technologies for developers. After going through the installation process, you can verify it by opening a command prompt.

When the program is activated, you can start the JavaScript interpreter. On theNode currently allows you to write JS in the DevTools console, on the command line. In order to exit the interpreter, press "Ctrl + C" twice, enter exit.

You can enter all the JavaScript you need in the interpreter. First, they make sure that the user is in the directory with the file, write: cd /path/to/the/file and wait until the desired directory opens. Next, type "node" to run the file. For example, they write "node filename.js" to activate "filename.js". You can omit the.js file extension by typing "node filename". Node assumes "filename" is a JS file.

NPM Basics

Node.js allows you to run JavaScript outside of the browser. To help manage external dependencies, the installation comes with NPM. In addition to storing project metadata, the package.json file also keeps track of these dependencies. The official Node documentation is the main reference for everything related to software.

Code can be divided into import and export modules. NPM provides an easier way to manage dependencies. Let's say we need to use Lodash in code. First initialize a new project by running npm init in the project directory. Upon request, fill in the necessary information about package.json. All metadata is stored here.

Lodash Download

Assuming the user is in the correct directory, do this by running npm install lodash. The dependency is downloaded to a folder named node_modules. She tends to accumulate many files as soon as they are entered.more dependencies in the project. After installing Lodash, create a JS file in the current directory that Lo Dash uses. It imports Lodash by calling the require function.

Basics of using NPM
Basics of using NPM

As mentioned earlier, Node.js provides an API. This is a built-in module that comes with every installation. You can import this code by also calling the require function. Running the JS file will write Hello World to text named dev to.txt.

This fs.writeFile method is just one of the many fs functions offered by the module. All available API methods and properties are described in the documentation.

Export modules

If you need to import your own code from different files, JS will first export the code of the JavaScript file. Then, using the require function, will load it into another. Actually, it's not as confusing as it seems.

Say there are four JS files in the same directory named index.js, add.js, username.js and dog.js. The job of add.js is to provide a function that returns the sum of two inputs. You can export it by assigning the add parameter to the module.exports property.

The job of username.js is to export the string Some Dood. Or whatever. This means that you can assign a value of any type to module.exports. This means that they export strings, numbers, booleans, symbols, functions, classes, arrays and objects.

Module export
Module export

You can call these three index.js files using the require function. Need to provideabsolute or relative paths to them to explicitly tell Node.js that they are importing from files and not from built-in modules or from the node_modules folder of the project, while you can omit the.js extension. The "required" function returns the actual value that was assigned to the corresponding module.exports file.

Installing and launching the application

A very simple first step into the world of JS is done using the command line and writing the first bit of code Node.

Algorithm for running Windows JS script:

  1. Download the latest version of the program, for example, V6.2.2.
  2. Install Node npm install following the instructions.
  3. After activation is complete, find the icon in the Windows search option and open the program.
  4. Now we can go ahead and do some calculations and try to print messages to the console.
  5. The steps will show that the node has been successfully installed on the system and is working properly.
  6. Press Ctrl + C twice to exit the node and get the directory path again.
  7. Set up the Windows command line environment for the application.
  8. Download and install from JS developer site Windows open.
  9. Run cmd.exe.
  10. Press Windows + R on the keyboard.
  11. Type cmd and press enter.
  12. Check if node installed successfully by typing node -v, it should reply "v.. ", where "" means number
  13. Reboot the computer if the -v host does not respond correctly.
  14. Try to automatically install all dependencies using npm commandinstall.
  15. Start the server by running "node application" in the root folder of the server.

If the previous step failed, install the dependency manually by running the following commands:

  • "npm install";
  • "npm install express -g";
  • "npm install url -g";
  • "npm install fresh -g";
  • "npm install cookie -g";
  • "npm install crc -g";
  • "npm install send -g";
  • "npm install connect -g";
  • "npm install commander -g".

Configuring Node JS Windows 10

Configuring NodeJS Windows 10
Configuring NodeJS Windows 10

Developing with js for Windows used to be pretty cumbersome, but now it's much easier. The network has the latest tools and applications with the ability to use the 64-bit version.

Installation algorithm:

  1. Install Git using default settings.
  2. The Projects folder in the home directory is chosen as the installation location, if it does not exist, then it is first created for the project.
  3. Right click on the folder, select Git bash here and check the git version by typing: git-version.
  4. Create a.bash_profile that will be executed when a bash window is opened. This is not a cmd.exe window, so check the options. Click on the icon in the top left corner. You can paste text using the middle mouse button, as on popular Linux terminals.
  5. Install Node.js on Windows 10 using the LTS version. Notit is recommended to activate multiple versions at the same time as the node manager (NVM) does not officially support Windows, but there are alternatives such as nvm-windows or nodist.
  6. Node comes with npm, a package manager available after installation.
  7. Open a bash shell and check versions with: npm --version. If npm is 2.x, you should update it to version 3, which solves many problems, such as handling peer dependencies.
  8. Find Powershell in the start menu, run it as administrator and install npm, the Windows 10 package manager.
  9. Activate Visual Studio and Python. Node packages usually depend on native code packages, so you need to install Visual Studio. Node-gyp is a wrapper for the Python GYP. It generates project files for Gcc, XCode and Visual Studio.
  10. Install Python by downloading the x64 branch. You can go with the default settings and also select the "Add to Path" option. This will add the Python binary to the global path, which means you will eventually have to log out and log back in.
  11. Install Visual Studio.

Node.js projects usually rely heavily on environment variables. You can use locally installed node modules in the script section of package.json. Recommend not to activate packages globally with npm –g.

To sum it up, building desktop applications using HTML, CSS, and JavaScript looks promising with Node. And utilities like Spotify, Light Table, and Brackets useopen source browser renderers. With node-webkit and atom-shell, developers can easily import web applications to the desktop and use Node and npm modules in the front-end with location-aware JS Windows.

Popular topic

Editor's choice

  • The Psijic Order from The Elder Scrolls - who are they?
    The Psijic Order from The Elder Scrolls - who are they?

    The Psijics are the name of a mysterious and ancient Order from the Elder Scrolls game universe. Its members practice magic and are notorious for being at odds with the Thalmor. Even more interesting information about the Psijic Order can be found in today's guide

  • Three easy ways to turn off notifications in Viber
    Three easy ways to turn off notifications in Viber

    "Viber" today is one of the most popular and widespread instant messengers. Sometimes a situation arises that the sound of constantly incoming messages bothers or distracts a person from important matters. How to turn off notifications in Viber? The article presents three of the simplest and easiest ways to do this, and they will help you set the silent mode on both Android and iOS

  • How to advertise on Instagram yourself?
    How to advertise on Instagram yourself?

    One of the most effective methods of website promotion and business development at the moment is advertising on social networks. Social networks, where people actively communicate, are more willing to pay attention to useful posts, join groups, like posts and make reposts, are an almost inexhaustible source of traffic. A properly built advertising campaign will allow you to get new customers, keep the attention of existing ones and again win over those who were dissatisfied with the service

  • Google - what is it?
    Google - what is it?

    The article talks about the multidisciplinary corporation Google. Its services and the company's work as a device manufacturer are considered

  • How to remove a user from important friends on VKontakte: all ways
    How to remove a user from important friends on VKontakte: all ways

    Important friends of "VKontakte" are determined automatically. When friends, family, and a loved one appear first on the list, this is convenient. But relationships can change for various reasons, and the need to constantly see a person’s page may disappear. In this article, we will tell you how to remove from important VKontakte friends those users whom you do not want to see at the top of the list