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.
CodePudding user response:
You can add any packet which is available by Openembedded Layer in your Yocto release. Please look to Openembedded Layer to find the packet you want. After that, you can add any packet via your local.conf file.
If you don't find the packet on the page, you need to compile it on your own using a compiler for your platform and add it manually by recipe.
CodePudding user response:
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:
- basic-auth_2.0.1.bb :
# 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