This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.
Please visit our production wiki at https://wiki.gentoo.org
NodeJS
This is a work in progress!
About Installation
This guide will walk through installing Node.js behind nginx and using Monit to keep Node instances alive. Since Node.js is a single-process application, we will launch multiple instances of the application and load balance using nginx.
Installation
USE flags
USE flags for net-libs/nodejs A JavaScript runtime built on Chrome's V8 JavaScript engine
+icu
|
Enable ICU (Internationalization Components for Unicode) support, using dev-libs/icu |
+inspector
|
Enable V8 inspector |
+snapshot
|
Enable snapshot creation for faster startup |
+ssl
|
Add support for SSL/TLS connections (Secure Socket Layer / Transport Layer Security) |
+system-icu
|
Use system dev-libs/icu instead of the bundled version |
+system-ssl
|
Use system OpenSSL instead of the bundled one |
corepack
|
Enable the experimental corepack package management tool |
debug
|
Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces |
doc
|
Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally |
lto
|
Enable Link-Time Optimization (LTO) to optimize the build |
npm
|
Enable NPM package manager |
pax-kernel
|
Enable building under a PaX enabled kernel |
systemtap
|
Enable SystemTap/DTrace tracing |
test
|
Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently) |
Emerge
root #
emerge --ask monit nginx nodejs
npm
Node.js has a USE flag to include npm, the Node.js package manager. You will need it to install a Node.js application's dependencies, which are defined in a file named package.json.
The current stable version of Node.js, 6.11.x, comes with npm 3.10.x.
If you need a newer version like npm 5.6.x, use Node.js 8.9.x (the next LTS release) or later. You can configure which version to pull in by setting keywords, e.g.:
/etc/portage/package.keywords/nodejs
~net-libs/nodejs-8.9.4
Also see Knowledge_Base:Accepting_a_keyword_for_a_single_package.
Configure Monit
/etc/monit.d/my-app
Auto restart NodeJS Appcheck process mysql with pidfile /var/run/my-app/mysqld.pid start program = "/bin/bash -c 'rc-service mysql start'" stop program = "/bin/bash -c 'rc-service mysql stop'"
Configure Nginx
/etc/nginx/nginx.conf
Nginx Confighttp { upstream myapp1 { least_conn; server srv1.example.com; server srv2.example.com; server srv3.example.com; } server { listen 80; location / { proxy_pass http://myapp1; } } }