TurnKey Linux Virtual Appliance Library

Node.js

-

Asynchronous Javascript Framework

Node.js is a cross-platform Javascript runtime environment built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, especially for server-side and networking applications. npm, Nodes package ecosystem is the largest ecosystem of open source libraries in the world.

Stable version: 14.1 (changelog)

This appliance includes all the standard features in TurnKey Core, and on top of that:

  • Node.js configurations:
    • n Node Version Manager used to install the latest stable version of Node. n supports updating Node to the latest version and switching between multiple older versions:
      # install latest stable node
      n stable
      
      # show all installable versions
      n list
      
      # install specific version
      n <version>
      
    • Support for installing npm packages globally more securely without root or sudo:
      su node
      npm install -g package
      
    • systemd PM2 service at /etc/systemd/system/pm2-node.service runs node apps on boot.

      pm2 is a production process manager that helps keep your node apps running, supports clustering and makes it easy to manage node apps:

      # su node
      $ pm2 start --max-memory-restart 500M /opt/yourapp/app.js
      $ pm2 stop tklweb-cp
      $ pm2 list
      
    • Default Nginx configuration template:
      server {
          listen 0.0.0.0:80 default_server;
      
          set $nodeapp_port 8000;
          include /etc/nginx/include/nodejs-proxy;
      }
      
    • npm bash tab-completion:
      $ npm in<tab>
      info     init     install
      
    • hundreds of node example apps:
      $ ls /opt/node-examples
      express_example  node-by-example  nodejsbook.io.examples  practicalnode
      
    • Default web page / control panel at /opt/tklweb-cp is itself an example Node.js app built with express and jade templating.
  • Bundled globally-installed Node.js packages:
    • PM2: production process manager. Configured to start on boot as a systemd service.
    • forever: a simple CLI tool for ensuring a node app runs continuously. Supports watching sources for changes and restarting app.
    • node-inspector: a powerful debugger modeled after Chrome devtools.
    • grunt: task runner that automates repetitive tasks like minifcation, compilation, unit testing and linting.
    • bower: package manager for client-side browser dependencies
    • nsp: Node Security Project package auditor. Audits dependencies for known security vulnerabilities:
      cd /opt/yournodeapp
      nsp audit-package
      
  • Postfix MTA (bound to localhost) to allow sending of email (e.g., password recovery).
  • Webmin modules for configuring Postfix.

Usage details & Logging in for Administration

No default passwords: For security reasons there are no default passwords. All passwords are set at system initialization time.

Ignore SSL browser warning: browsers don't like self-signed SSL certificates, but this is the only kind that can be generated automatically without paying a commercial Certificate Authority.

Web - point your browser at either:

  1. http://12.34.56.789/ - not encrypted so no browser warning
  2. https://12.34.56.789/ - encrypted with self-signed SSL certificate

Username for OS system administration:

Login as root except on AWS marketplace which uses username admin.

  1. Point your browser to:
  2. Login with SSH client:
    ssh root@12.34.56.789
    

    Special case for AWS marketplace:

    ssh admin@12.34.56.789
    

* Replace 12.34.56.789 with a valid IP or hostname.