OpenEmbedded layer for latest stable Node.js releases.
Stable releases of Node.js:
5.x4.x(LTS)0.12.x(LTS)0.10.x0.8.x
nodejsnodejs-npmnodejs-dtracenodejs-systemtapnodejs-wafadmin(only with Node.js0.8)
Layer installation varies depending on your OpenEmbedded distribution. These instructions are generic.
-
Fetch
meta-nodejslayer fromhttps://github.com/imyller/meta-nodejs.git -
Add
meta-nodejslayer toEXTRALAYERSinconf/bblayers.conf. For example:EXTRALAYERS +=" \ ${TOPDIR}/sources/meta-nodejs \ "
To build latest stable Node.js package:
bitbake nodejsAdd Node.js as a dependency in recipe with RDEPENDS (for runtime) or DEPENDS (for build):
DEPENDS += " nodejs"
RDEPENDS_${PN} += " nodejs"Inherit npm-install build task classes in your recipe. This will automatically add node to your RDEPENDS_${PN} and node-native to DEPENDS.
meta-nodejs layer adds few Node.js related helper classes.
npm class defines following functions:
oe_runnpm: call cross-compilingnpmoe_runnpm_native: call native-compilingnpm
For example:
inherit npm
do_install() {
oe_runnpm install # Installs dependencies defined in package.json
}NPM_FLAGS: Extra command line arguments fornpmcalls made byoe_runnpm()NPM_ARCH: Override npm target architecture (defaults toTARGET_ARCH)NPM_REGISTRY: override npm registry URL
npm-install class inherits npm class and adds following build tasks (listed in their run order):
npm_install: runsnpm installin source directorynpm_shrinkwrap: runsnpm shrinkwrapin source directorynpm_dedupe: runsnpm dedupein source directory
You can disable one or more of these build tasks in the recipe with do_<taskname>[noexec] = "1":
do_npm_shrinkwrap[noexec] = "1"NPM_INSTALL_FLAGS: Extra command line arguments fornpmcalls made innpm_installtaskNPM_INSTALL: Parameters fornpm installcommand (such as specific package names)
npm-install-global class inherits npm class and installs the selected package globally.
This is done in the do_install task of the class.
NPM_INSTALL_FLAGS: Extra command line arguments fornpmcalls made indo_installanddo_configuretask
grunt can build a package that is based on grunt.
First it will do an npm install during the do_configure task to make sure all
dependencies are available.
Then it runs grunt with the default target during the do_compile task.
It defines the following functions:
oe_rungrunt: callgrunt
NPM_INSTALL_FLAGS: Extra command line arguments fornpmcalls made indo_configuretaskGRUNT_TARGET: The grunt target to run. (default: "")
gulp can build a package that is based on gulp.
First it will do an npm install during the do_configure task to make sure all
dependencies are available.
Then it runs gulp with the default target during the do_compile task.
It defines the following functions:
oe_rungulp: callgulp
NPM_INSTALL_FLAGS: Extra command line arguments fornpmcalls made indo_configuretaskGULP_TARGET: The gulp target to run. (default: "")
bower is a package manager for web applications front-end dependencies: bower.io
bower class defines following functions:
oe_runbower: callbowercommand line utility
BOWER: bower command line utility (default:bower)BOWER_FLAGS: Extra command line arguments forbowercalls made byoe_runbower()BOWER_REGISTRY: override Bower registry URL
Suppose a web application has front-end dependencies which are listed in the file
bower.json. In this case the web application recipe can auto-install all those
dependencies during yocto build by inheriting bower-install class.
bower-install class inherits bower class and adds following build tasks:
bower_install: runsbower installin source directory afterdo_npm_dedupeand beforedo_install
Note that front-end dependencies are auto-installed into build directory. They have to be
explicitely copied into target image in do_install or do_install_append. Here is a
simple example of web application recipe with nodejs and bower dependencies:
SUMMARY = "simple web application with JS front-end dependencies listed in bower.json"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690"
SRCREV = "${AUTOREV}"
PR = "r0"
PV = "0.0.1+git${SRCPV}"
SRC_URI = "git://webapp.example.org/test.git;branch=master;protocol=ssh"
inherit bower-install
S = "${WORKDIR}/git"
do_install () {
install -d ${D}/www/test/public
cp -r ${S}/bower_components ${D}/www/test/public/
}
BOWER_INSTALL: Parameters forbower installcommand (such as specific package names)BOWER_INSTALL_FLAGS: Extra command line arguments forbowercalls made inbower_installtask

