I would like to have an OS which support nodejs. In my yocto project at layer.conf file I add IMAGE_INSTALL_append = " nodejs" IMAGE_INSTALL_append = " nodejs-npm" which result in to have an OS with nodejs support afer bake. Now I want to add some NPM packages also like basic-auth etc. would you please help me. kind regards.
In order to add an npm
package into your image, you need to create a recipe for it.
Yocto has an npm
source scheme handler, and you can use registry.npmjs.org
to create a recipe fetching your wanted package.
Create a recipe with devtool:
devtool add "npm://registry.npmjs.org;name=basic-auth;version=latest"
You can set a specific version as well.
The recipe would be the following:
# Recipe created by recipetool
# This is the basis of a recipe and may need further editing in order to be fully functional.
# (Feel free to remove these comments when editing.)
SUMMARY = "node.js basic auth parser"
# WARNING: the following LICENSE and LIC_FILES_CHKSUM values are best guesses - it is
# your responsibility to verify that the values are complete and correct.
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=42fffe6fe0b70501d52150ebb52113df \
file://node_modules/safe-buffer/LICENSE;md5=badd5e91c737e7ffdf10b40c1f907761"
SRC_URI = "npm://registry.npmjs.org/;name=basic-auth;version=latest"
NPM_SHRINKWRAP := "${THISDIR}/${PN}/npm-shrinkwrap.json"
inherit npm
# Must be set after inherit npm since that itself sets S
S = "${WORKDIR}/npmpkg"
LICENSE_${PN}-safe-buffer = "MIT"
LICENSE_${PN} = "MIT"
It compiles correctly.
You can move it to your custom layer after testing it with devtool
:
devtool finish basic-auth <path/to/meta-custom> or
devtool finish basic-auth <layer/in/bblayers.conf>
For more information about npm
handling check this link
I encourage you to read more about Yocto NPM
handling in their official documentation in this link
EDIT:
If you encounter the error:
is missing the required parameter 'Parameter 'package' required'
just change name
to package
:
devtool add "npm://registry.npmjs.org;package=basic-auth;version=latest"