TKL Node.js

The next image, as its title suggests brings the node.js framework, which consists of Google V8 JavaScript Engine and other standard libraries and allows to create highly scalable web applications, servers, etc. It is a JavaScript framework, with efficient package management and a wide ecosystem of open source applications being its main advantages..

If you enter the IP address of this machine into the address bar of the browser after the machine with the given image is started, the control panel will appear, which will guide you to the shellinabox and webmin administration tools. You can find further information regarding these tools in the description of the TKL core image or in the particular separate manuals. The adminer tool is not available inside the given image.

However, there is n, the node.js version manager available, which allows to carry out updates, installation of a particular version or switching between particular available versions of Node.js really easily. The broader description of this utility is beyond the scope of this manual, however, we state some commands regarding the desired version of node.js in an attempt to make the process of getting up and running faster.

  • The node –version command will show the currently used version of the node.js
  • The n list command will list all the version of node.js available for installation
  • The n <version> command will install the particular desired version of the node.js (replace the <version> string with the expression denoting the desired version)
  • The n stable command will install the last stable version of node.js available
  • The n latest command will install the last version of node.js available
  • The n lts command will install the last long term support version of node.js available
  • The n rm <version> command will uninstall the particular version of node.js (replace the string <version> with the expression denoting the desired version); it is possible to use instead of rm
The control panel at the IP address of the machine with TKL node.js installed

If we enter just the n command into the shell, a list of available installed versions of node.js will be shown (the currently used version is denoted by a bullet) and we can use the arrow keys to choose the version we want to use, confirming it by hitting Enter key; we can verify the successful transition to the desired version of the node.js using thenode -version command.

There is also the node.js npm module, that is the node.js (or more precisely JavaScript) package manager. The basic help for this command can be obtained with use of eithernpm help or npm faq command. In order to get some broader help, you can use e.g. either the npm help npm -l command or the online documentation. Beside the default local installation of the packages, it is possible to install the packages globally with npm . Should the command npm not work after switching to another version of node.js using the n <version> command, downloading and running the additional installation script may sort out such troubles. The command for doing so is available on the official documentation pages of the n command, that is at: https://github.com/tj/n .

There is also the pm2 command available inside the given image, that is the production process manager for node.js, which allows to run and manage the particular node.js applications both manually and automatically. The pm2 service file is located in /etc/systemd/system/pm2- node.service, so that it spawns all the node.js applications located in the respective pm2 directory, after the machine is started. The official documentation of the pm2 tool is available on GitHub and on the official website . We will state only a few basic commands regarding the management of the node applications using pm2:

  • The pm2 command will show the basic help of the given utility
  • The pm2 list command will list the running node.js applications and basic information regarding these
  • The pm2 <application> command will show the list (table) and basic information regarding the running node.js applications (replace the <application> string with the title or id of the given app)
  • The pm2 show <application> command will show the detail information regarding the running node.js application (replace the <application> string with the title or id of the given app)
  • The pm2 logs <application> command will show the log of the running node.js application (replace the <application> string with the title or id of the given app) in a real time; use Ctrl + c for exiting the view of the log
  • The pm2 start <application> command will run the given node.js application (replace the <application> string with the title or id of the given app)
  • The pm2 stop <application> command will stop the given node.js application (replace the <application> string with the title or id of the given app)
Using the process manager for node.js – pm2

The TurnKey Linux node.js image contains all the components mentioned in the description of the TKL core version and on top of that:

  • Nginx – web server, currently the version 1.6.2
  • Node.js – JavaScript framework, currently the version 5.10.1
    • n – node.js version manager
    • npm with the support for installing packages globally
    • pm2 – the node.js processes and applications manager
    • node.js application examples in /opt/node-examples
    • the control panel of the given TKL image as a node.js application located in /opt/tklweb-cp
  • Node.js modules pre-installed globally:
    • pm2 – node.js process and application manager, run on boot as a systemd service
    • forever – simple CLI utility for applications continual operation
    • node-inspector – utility for application debugging
    • grunt – a scheduler for the planning tasks allowing for the automation of the desired tasks, such as compilation , testing, etc.
    • bower – the client side browser dependencies package manager
    • nsp – node security project package auditor – auditing of dependencies regarding the known security vulnerabilities
  • Postfix – email server, bound to localhost
  • The Webmin modules for the configuration of Postfix
  • Python – programming and scripting language, currently the version 3.4.2
  • SSL support

The official documentation of the TKL node.js image is available at: https://www.turnkeylinux.org/nodejs .